so after trying awhile to compare a const char* to a string, I read that I'm supposed to compare using the strcmp method. But I'm still not getting a correct comparison to a string. While debugging, my text values look fine so I'm stumped. I'm trying to compare values in my std::map like so -
so after trying awhile to compare a const char* to a string, I read that I'm supposed to compare using the strcmp method. But I'm still not getting a correct comparison to a string.
The comparison is correct. Are you saying that strcmp() or std::string::compare has bugs? Obviously, what's behind that variable is not the string "Neighbor", as you claim it to be, since there is no chance that both of these functions have bugs comparing simple strings (if that were the case, thousands of programmers would have reported it).
While debugging, my text values look fine so I'm stumped.
There is a difference between how it looks in the debugger and what that value really is. If you took the time to output each character in a loop, or you did a more thorough inspection using the memory window of the debugger, you will see that the string is not "Neighbor", but possibly a string that contains control characters or spaces that are not visible under ordinary circumstances.
Also, after 97 posts, you don't know how to properly use code tags?
Regards,
Paul McKenzie
Last edited by Paul McKenzie; July 1st, 2012 at 10:23 PM.
Bookmarks