CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #3
    Join Date
    Apr 1999
    Posts
    27,449

    Re: trouble with strcmp

    Quote Originally Posted by drwbns View Post
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured