c++ - Str.compare() or (string)A == (string)B for string comparison -


i writing compiler reads file line line, checks line command (eg. d=am), splits substring , finds out each command was.

should using str.compare() or can use if statement below?

tempstring = line.find("=", line.length()); if(tempstring == "am"){return 65526;} 

there doesn't seem of difference between 2 except using == return bool, while using str.compare() return int (specifically 0 if true, need use if(str.compare(str2) == 0) ). can see more compare function @ http://www.cplusplus.com/reference/string/string/compare/ .


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -