LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   c++ newbie - help debug simple program please (https://www.linuxquestions.org/questions/programming-9/c-newbie-help-debug-simple-program-please-120342/)

mymojo 11-26-2003 10:40 PM

c++ newbie - help debug simple program please
 
#include <iostream.h>

int main ()

{

int mypin;
int brutepin;

mypin = 5178;
brutepin = 0000;

cout << "Trying to match PIN: " << mypin << endl;

// go through possibilities


for ( brutepin != mypin; brutepin++ );



// final check

if ( brutepin == mypin )

{

cout << "Successfully found PIN. It was: " << brutepin << endl;

}

else

{

cout << "Could not find PIN. Sorry";

}


return 0;

}

wapcaplet 11-26-2003 11:33 PM

What errors do you get when you try to compile? Hard to debug a program just by looking at it :)

Edit: nevermind. Your "for" syntax is incorrect. Try this:

Code:

for ( ; brutepin != mypin; brutepin++ );

mymojo 11-26-2003 11:38 PM

I'll give that a whirl. Thanks.

mymojo 11-27-2003 02:29 AM

Yep. It works. Thanks!

Wow! It figures it out in less than a second!

I wonder how long it would take with letters & numbers & *, -, _ etc...

That's the next step!

nowonmai 11-27-2003 04:17 AM

There's a Cray Y-MP with a guest shell account somewhere on the net... try running it on that :D


All times are GMT -5. The time now is 04:40 AM.