Prabakar 77 Posting Whiz

I am pretty confident that experts in this forum wont like talks about turbo c++. well, I shall give you a clue.

getch() does not echo the char typed yet reads it.
putch() can be used to put a char of your liking.

Need you know anything more than this to solve the problem?

Coming to compilers. My academics has limited me to turbo c++ for some time untill I joined this fourm, where as you can start with the right compilers. Code::Blocks, Dev C++ & Visual C++ (express edition) are 32 - bit free compilers and provides you both win32 & console application. You can start with them on the first hand.
My suggestion, Uninstall Turbo C++, Like i did

Prabakar 77 Posting Whiz

Do you want to encrypt your file. Or just the * when the password is typed?

If you want to hide the password when user types check my post else

Google for MD5 or SHA or any such algorithm to encrypt the file so that the contents will be confidential.

Prabakar 77 Posting Whiz

1) Don't use void main
2) Don't use Turbo C++
3) If it is a must to use Turbo C++, try getpass() or write one on your one to simulate it. Its ain't difficult.

Prabakar 77 Posting Whiz

I wrote 2 programs. 1 prog constantly rights a file. 1 program reads the content & finnaly tries to delete the file. I run the first program & then the second. the second was able to get the data from the file( without updated records) but as AD said the prog was not able to delete it.

Prabakar 77 Posting Whiz

Well, I ain't know this for sure, but please do try to replace getch() with scanf() or getchar()

Prabakar 77 Posting Whiz

RGB is a macro that takes 3 integer & returns a COLORREF & not a function, I believe. The link niek_e gave had rgb() & not RGB() So I am not sure whether I am right. Give it a try.

EDIT:
I refered MSDN RGB is indeed a macro Thats why you did not find it in object browser

Prabakar 77 Posting Whiz

I don't have a turbo c compiler at home, though I am forced to use it in college.

Is it the case with you too? If not, the 32 bit world offers better ways to do everything.

I had a glance of your code & I want to say something

1) Formate your code
2) Use Code Tags
3)

while(!kbhit()){
if (kbhit())
c=getch();
}

When you want to wait indefinitely, just c= getch() will be enough.

4) calling scene() in call() & call() in scene() Does the program end? That may be the reason for the flashing.

Hope it helps:)

Lastly, Could you please state the problem.

EDIT:

There is something more that I want to say.

Console output did not work for me in graphics mode. perhaps console input too does not work & it may also be a reason for the flashing(not sure) I shall test it in college tomorrow.

Prabakar 77 Posting Whiz

My Problem:
I have lots of virus & Trojan horses in my Pen drive. I don't have any valuable data though.

If I plug in the drive in my USB port, the viruses do something & I loose my internet connectivity & it also occupies more space memory. Without knowing what to do, I have formated my hard-drive & reinstalled Win XP and various softwares. So now my computer is free from virus.

Question:

How would I delete the virus in my pen drive & at the same time protect my computer. (I don't need the data in it)

Please help

Prabakar 77 Posting Whiz

>>you can save the new data in program A after each step

I guess he said program A is not in his hands.

Prabakar 77 Posting Whiz

you hate recusion? Thats bad

When i first learned it. It was fun.

Recursion makes things simple for you. Programs like towers of honai, Infix to postfix, tree traversals are very much easy when we use recursion.

The problem with me is that I DONT know where to use it & where not to. thats why I choose the loops. But no way I would hate it, for my inability.

So, try to love it:)

Prabakar 77 Posting Whiz

curiously, Is it a must to use recursion for this problem?
I ask because, my poor usage of recursion makes me run out of stack memory many times, so i tend to avoid it completely.

Prabakar 77 Posting Whiz

ya its right.

power == 1 will be handled by
return base * pow( base, power-1 );
so 2nd if though right, its not needed

I've edited the previous post have a look at it

Prabakar 77 Posting Whiz

one more
if ( power % 2 != 0) & not power % 2 == 0

The code is working good for positive numbers as I thought.

int pow ( int base, int power )
{
     if ( power )                                                          // if not 0
     {
          if ( power % 2 ) // if odd then 5^7 say == 5*5^6
              return base * pow( base, power-1 ) ;
          return pow ( base * base, power/2 ); // else if even, then the shortcut your book said
     }
     return 1 ;   // if 0 then return 1 since any^0 = 1 ;
}

Now, have I made myself clear?

Prabakar 77 Posting Whiz

if ( power > 0 ) is what i meant not >= 0. Now that you said it, I'll get rid of my laziness & check my code I shall reply soon if there is a change.

Prabakar 77 Posting Whiz
#include <cstdlib>
#include <iostream>

using namespace std;

int main( )
{
    int pow ( int, int ) ;
    return EXIT_SUCCESS;
}

int pow ( int base, int power )
{
     if ( power )
     {
          if ( power % 2 ) return base * pow( base, power-1 ) ;
          return pow ( base * base, power/2 );
     }
     return 1 ;
}

This is a code I came up with. I must admit that I did not test it. I dont know if it will work with all cases ( 5 ^ -2 ). I am confident though that it will work with positive numbers unless ofcourse you give big values to crash the program. Hope you can build on this code to deal with all cases:)

Prabakar 77 Posting Whiz

nice catch stephen84s. Then I guess the only way should be to play with bitwise operator

Prabakar 77 Posting Whiz

so I might be completely wrong

You are not completely wrong:). Cause I like it!!! I'll give you a rep just for that link

Prabakar 77 Posting Whiz

>>You are not blaming me for anything else. Does that mean I am right?.
No, it just means that line had a typ. To check if you are right or wrong you have to compile and run the program.

>>ill I registered in this forum the only world I knew was Turbo C.
Great move :) I'm sure you won't regret the move.

Thanks again. Well, Its getting late. got to sleep. Good night to people in my time zone

Prabakar 77 Posting Whiz

Ya I noticed it. You are not blaming me for anything else. Does that mean I am right?.

As I said before, I am new to win32. Till I registered in this forum the only world I knew was Turbo C.

Prabakar 77 Posting Whiz

I cant explain much cause i am very new to win32 programs and then try this,

MessageBox( NULL, TEXT("Welcome"), NULL, NULL ) ;

EDIT: I should not have talked about something which I don't know:(

Prabakar 77 Posting Whiz

A makefile is a text file that tells a compile how to compile and link a program. Tutorial here.

Thank you:) I'll read it.

Prabakar 77 Posting Whiz

Why is that I am not able to understand what you are talking? I was never thought about MAKEFILE :( What is a makefile?

Prabakar 77 Posting Whiz

Ya thats what I was taking about & it would be better if lines 9 to 15 get inside do while loop.

And perhaps every case needs a do while!!

Prabakar 77 Posting Whiz

Dequeue is simple. since it is a queue you need head & tail. I don't know what you are trying to do with new_num. So I'll leave it. And it seems you want to delete all nodes in the queue with the dequeue() Actually dequeue deletes just the first node. so a code like this would do.

bool dequeue()
{
      // check if empty
   temp = head ;
   if ( head == tail ) 
     head = tail = NULL ;
   else 
     head = head-> link ;
   delete temp ;
}

Hope it helps:)

Prabakar 77 Posting Whiz

Put the switch case inside do while

Prabakar 77 Posting Whiz

I guess you misunderstood. The moment I found that it came from a dangerous website ( site Advisor Said that to me) I uninstalled the smiley toolbar. But now the IE7 opens every daniweb page with this in the status bar "Done, but with errors on page" And I am not able to use the toolbar provided by daniweb to quote or code etc.

This is a problem that happened after the uninstallation of the toolbar & the reg keys I deleted. I guess I should not have delt with something I dont know. I am going to try mozzila in the mean time.

Prabakar 77 Posting Whiz

Yes, I know of it. But what should I do

Prabakar 77 Posting Whiz

I am having problems with using the icons like bold, code, quote, etc (the entire toolbar). This is the first time I am experiencing it. I am using IE7 & also I am not able to use the save, cancel buttons while editing too. In other words I am not able to edit my message. What should I do?

In the status bar it shows error. I don't know much about Internet please help with simple words.

Its embarrassing so say that I am a student of IT & yet know nothing about Internet or web browser. I know the easiest way. That is to reinstall the browser. But that would be running away from the problem & not solving it. I thought If I post it here at least I would gain some knowledge.

I believe Any problem can be solved by going back to the past. I will try to remember the resent events that happened relating to this.

I uninstalled AVG Free Version & Installed Mccafee. Mccafee found a Trojan horse & a ad-ware & removed it. The source of ad-ware was a smiley toolbar that I installed.

I installed a reg cleaner. In which there was a Internet Explorer BHO Organizer Tab. In that I removed some reg keys which did not have a name & BHO Executable file, believing that they where traces left by the virus. Ofcorse I dont know what is BHO Executable file

I can recollect …

Prabakar 77 Posting Whiz

Now, Did you really code that merge sort program? And is it really working?

Alex suggestion was correct, I just wanted to show the calculation part. The code I wrote would have worked well, but its not practical, as he said you should increment the index at creation time.

I think to sort the other way is very very very difficult. Its too complex that I just cant help you:(

Prabakar 77 Posting Whiz

I am preety lazy to use merge sort. The trick is to have an array of index which originally has numbers from 1 to n. and sort it along with the array. Here is a simple code.

#include<iostream>
using namespace std ;
int main ( )
{
    int a[] = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 } ;
    int index[11] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
    int i, j; 

    for ( i=0; i<10 ;i++ )
        for ( j = i+1 ; j < 11 ;j++ )
            if( a[i] > a[j] ) 
            {
                a[i] = a[i]+a[j] ; index[i] = index[i]+index[j] ;
                a[j] = a[i]-a[j] ; index[j] = index[i]-index[j] ;
                a[i] = a[i]-a[j] ; index[i] = index[i]-index[j] ;
            } 
     for ( i = 0 ; i < 11 ; i++ )
         cout << i+1 << "." << a[i] << " " << index[i] << endl ;
     getchar ( ) ;
}
Prabakar 77 Posting Whiz

I read few lines of code. And so far I have found some silly mistakes

1) if (! argc > 1) will always fail because ! has higher priority than >

this priority stuff confuses me a lot so I always use () to aviod the confusion

2) the string file was never assigned a value.

Besides this need you open the same file twice ( once in main & once in sub_fn )

Prabakar 77 Posting Whiz

I will say that you have to think the way AD thinks

Edit: Too late

Prabakar 77 Posting Whiz

dont use trubo c. If you search this forum you would know why.

Prabakar 77 Posting Whiz

the code is not intended properly, that's why we assumed missing {}. you have at least that right. I successfully found all { & }. 10 points to Prabakar:)

What is the operation variable doing? You never assigned a value for it.

I guess the program in itself incomplete. Are you planing to provide all basic arithmetics through the program?

why is the main fn returning a variable operation?

Could you state the problem more clearly?

And I would say there are limits for integers or even for floats, you cannot have infinite multipliers!!

Prabakar 77 Posting Whiz

Hey, when I googled the algorithm I found this,

http://www.cs.ualberta.ca/~zaiane/courses/cmput499/slides/Lect10/sld053.htm

Hope it helps

Prabakar 77 Posting Whiz

If thats the way you want to put it then, yes.

the diference is that if statement does not return any thing, but ?: returns the result.

5?a=1:0 ; returns 1, which is assigned to 'a'
thats why you have the error when return 1 canot be assigned to a variable.

This is only a guess, I am not sure what I say is the correct fact.

Prabakar 77 Posting Whiz

What is the reson that you will give, for the following to be wrong

1. a = return 5 ;
2. a = if( b ) ;

The same argument would go for that too.

Prabakar 77 Posting Whiz

try,
return x?1:0 ;

Prabakar 77 Posting Whiz

x = new int**[dim1];
x[0] = new int*[dim1 * dim2];
x[0][0] = new int[dim1 * dim2 * dim3];

Mine Mine, So far I have been using for loops for this. I cant imagine how stupid I was. Thanks guys.:)

Prabakar 77 Posting Whiz

I read the program & I understood. It is a nice & Thanks a lot.
I want to write the same in windows based, and I will try & soon after I finish, I will ask for improvements. Ofcourse this would be my first windows based program.

And also I have never ever used enum before because I dint know where to use it. you have just shown me a way of using it, thanks for that too.

Prabakar 77 Posting Whiz

>> C:/abc.exe is Not recognized

I guess you should use backward slash '\'

Prabakar 77 Posting Whiz

Yes yes he's right. It should work.

Prabakar 77 Posting Whiz

Oh, I didnt see your reply, try
system( "\"//192.168.23.5/c/abc.exe\"");

Prabakar 77 Posting Whiz

Will this work?

system ("explorer http\\\\192.168.23.5");

Prabakar 77 Posting Whiz

You are not going to add any 0's Its already there in the text file isnt it, just skip '\n' in a if statement & read the file char by char. use mod like ed did & the code will be fine

Prabakar 77 Posting Whiz

Well, I have to agree with what you said, and at the same time what I really wanted to say was the memory allocated may be dynamic but the memory allocated to reference this dynamic memory during compile time will be in order. That is the pointers a & b will be consecutive. Of course the memory referenced by them may not be, for all the reasons you mentioned.

EDIT:
Using new is better, I do know of it yet lets say I still stick to C, I'll change myself though, thank you

Prabakar 77 Posting Whiz

Both structure and class objects should be allocated in the order in which they are declared. If allocated dynamically then the memory will be in some memory that is unknown to the program (the memory allocation functions will of course know).

I agree with Dragon, even if a random memory is acquired when malloc is used, the pointers in the class should occupy memory in the order they are declared. This is a code wich proves this point

#include<iostream>
#include<stdlib.h>
using namespace std ;

class c
{
public:
	char *a ;
	c ( ){
		a = (char *)malloc ( 50 ) ;
		b = (int *)malloc ( 50 ) ;
		cout << (unsigned)&(this->a) <<endl ;
		cout << (unsigned)&(this->b) ;
	}
	int *b ;
} ;

int main()
{
	c cobj1, cobj2 ;
}
Prabakar 77 Posting Whiz

I posted an Identical thread in c fourum & but mine was faster though. It takes a few minutes to find a combination. & then to improve the performance, I'll give the same link I recived Warnsdorff's Algorithm

Prabakar 77 Posting Whiz

Use a struct on the first hand & since it is c++, its easy to swap a struct.

Prabakar 77 Posting Whiz

Ya! Good to see me right in something.