what is the difference?
#1

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'
Reply
#2

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)'
Reply
#3

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?
Reply
#4

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
Reply
#5

Ok, well that awnsered my question. Thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)