Hi!
It looks a bit tricky to me, so please let me know if I understand
this piece of code correctly:
if(!strcmp(str1,str2);
strcmp returns 0 if str1 = str2
strcmp returns 1 if str1 > str2
strcmp returns -1 if str1 < str2
so, if(!strcmp(str1,str2) actually sets strcmp to 1, i.e. to true;
because when strcmp returns 0, meaning that str1 = str2,
if I use "if(strcmp(str1,str2)" I will get "false" as the result
(because strcmp(str1, str2) will equal 0); by negating it
I actually get "true" as a result, and if(!strcmp(str1,str2)
means that both strings are equal. Correct?
When strcmp(str1,str2) returns 1, by negating it I am puting
the condition to false, so if(!strcmp(str1,str2) has the condition
of 0, and thus false. Correct?
If the above is correct, what happens when I get strcmp(str1,str2) = -1?
Thanks a lot!