This is making me crazy. This is the syntax I'm dealing with, and I just can't decide whether this statement results in 'true' or 'false'. I thought I understood this, but if I understand this correctly, then the code is 'wrong', or at least it definitely doesn't make sense to me.
if (!strcmp(str1, str2))
I understand(I think) that strcmp returns 0 if the strings are equal, and I understand(I think) that the ! is 'not' or reversing the result. Is that correct?
- So, if str1 = str2, then the strcmp returns 0, and the ! reverses that and makes it a 1, returning 'false' to the 'if'?
- and, if str1 <> str2, then the strcmp returns 1, and the ! reverses that and makes it be 0, returning 'true' to the 'if'?
- and then, since the if statement executes the subsequent actions only if true, then the subsequent actions would only be executed if str1 <> str2?
My problem is that the subsequent statement only makes sense if it's being executed when str1 = str2.
Help.