The Difference Between !strcmp & strcmp
#5

Strcmp returns 0 when the strings match and 1 when the strings don't match. When you check a statement with !, you're checking if it returns 0, otherwise you're checking if it doesn't return 0.

pawn Code:
if(something())
is a check for the function something() returning something other than 0.

pawn Code:
if(!something())
is a check for the function something() returning 0.


If you're confused by the way strcmp works, use this macro:

pawn Code:
#define strsame(%0,%1,%2) (!strcmp(%0, %1, %2))
pawn Code:
if(strsame("Hello", "hello", true))
{
}
Reply


Messages In This Thread
The Difference Between !strcmp & strcmp - by Dennis_Smith - 17.11.2012, 01:08
Re: The Difference Between !strcmp & strcmp - by Jefff - 17.11.2012, 01:33
Re: The Difference Between !strcmp & strcmp - by Dennis_Smith - 17.11.2012, 01:41
Re: The Difference Between !strcmp & strcmp - by [NRG]Dark - 17.11.2012, 01:46
Re: The Difference Between !strcmp & strcmp - by SuperViper - 17.11.2012, 02:21

Forum Jump:


Users browsing this thread: 1 Guest(s)