C++ syntax help

Status
Not open for further replies.

Tech2011

Solid State Member
Messages
13
Hello all!
I'm a newbie when it comes to C++ and I need some help checking some syntax.

Code:
srand(time(0));
int cor=rand() % 99999;
string user;
cin >> user;
cin.ignore();
if (user==cor)
{
cout << "Password entered is correct, you may exit the program now.";
exit(1);
}
else
{
cout << "Password is INCORRECT. Application will not terminate.";
}

Any advice I can get would be greatly appreciated! Thanks so much!
 
The compiler error I get is "no match for 'operator==' in 'user == cor' ". Any advice or assistance on this error is always appreciated!
 
It's because you're trying to use an integer operator to compare an int against a string. I.e cor is an int, user is a string, == compares integer values.
 
Thanks everybody! I found the problem. I guess it was a problem comparing the user string to the cor int. I just decided to make the user string into an integer. Thank you S0ULphIRE for the suggestion.
 
Status
Not open for further replies.
Back
Top Bottom