How can I compare C- string with C++ string? -


i want find out why compare function doesn't give me correct result ?

as know should return 0 if 2 string same!

bool validatepassword(char id[], string password) {      // cannot same id string     if(password.compare(id) == 0) {         cout << "password can not same id\n";         return false;     }      return true; } 

as matteo italia mentioned in answer's comment. use std::string's operator== this:

bool validatepassword(char id[], string password) {     return password == id; } 

this function unnecessary because caller should call operator== directly instead.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -