I want to find out why compare function doesn't give me correct result ?
As I know it should return 0 if two string are the same!
bool validatePassword(char id[], string password) {
// cannot be the same as the id string
if(password.compare(id) == 0) {
cout << "password can not be as same as id\n";
return false;
}
return true;
}
"hoge\n"
with"hoge"
and the reason for not giving correct result may be that the input is wrong. – Berkiestrcmp(password.c_str(), (char*)id)
? I'd have to go with MikeCAT and say the input string for 'id' may not be null terminated or something. – Geopoliticsstrcmp(password.c_str(), id)
without the meaningless cast? – Berkie