Page 1 of 1

Why do we even use strcmp???

Posted: Sun Nov 14, 2004 1:11 pm
by tores
I have done some small tests using === and strcmp(), and they gave the same results on the same strings... Personally I think it's a lot easier to use === instead of strcmp, but since strcmp is available I guess it is more secure than ordinary comparison. Is there some cases where the === operator will fail, and strcmp not?

Regards tores

Posted: Sun Nov 14, 2004 1:24 pm
by rehfeld
well strcmp can return < or > as well as 0 if they are equal. so it offers more functionality than == or ===

but i rarely use it, if your just checking if its the same or not, === or !== is what i usually use.

Posted: Sun Nov 14, 2004 2:09 pm
by timvw
with strcmp is that you the risk for a typo is smaller...

everybody will type = instead == or === some day...