what is the difference? -
Don_Cage - 18.05.2013
Some people does like this
pawn Код:
if(strcmp(cmd, "/cmd", true) == 0)
and some people do like this
pawn Код:
if(!strcmp(cmd, "/cmd", true) == 0)
what is the difference between putting the '!' and not doing it in just that place?
EDIT: and also what is the '== 0' about? I mean you can still make exact cmd without the '== 0'
Re: what is the difference? -
SchurmanCQC - 18.05.2013
If the '!' is present, you do not need '== 0'. I believe having both is a
double negative.
! means either 0 or false.
When ! is not present, it means equal to 1 or true.
You can void both of the above by including '== (VALUE)'
Re: what is the difference? -
Don_Cage - 18.05.2013
So i must either do
pawn Код:
if(!strcmp(cmd,"/cmd",true))
or
pawn Код:
if(strcmp(cmd,"/cmd",true) == 0)
or can i do
pawn Код:
if(strcmp(cmd,"/cmd",true))
and remove both?
Re: what is the difference? -
SchurmanCQC - 18.05.2013
Quote:
Originally Posted by Don_Cage
So i must either do
pawn Код:
if(!strcmp(cmd,"/cmd",true))
or
pawn Код:
if(strcmp(cmd,"/cmd",true) == 0)
or can i do
pawn Код:
if(strcmp(cmd,"/cmd",true))
and remove both?
|
You can use the first or second.
The third will see if the string is not equal, so it will execute if you type anything
except /cmd.
This all depends on what strcmp returns.
STRCMP returns false or 0 if the string is equal or one is empty.
STRCMP returns true or 1 if string 1 comes after string 2
STRCMP returns -1 if string 2 comes after string 1
Re: what is the difference? -
Don_Cage - 18.05.2013
Ok, well that awnsered my question. Thank you