Useful Snippet
#1

Hey guys!
I haven't seen one of these yet, & I made one a while ago to use in my scripts. It's a small stock to check if a string is empty. It works identical to the PHP function, empty, hence the same function name. It's a tad shorter than using strcmp. If someone has already done this then ignore mine, just figured someone could use it.
pawn Код:
stock empty(const string[])
{
   new _s=(string[0]!=0)?0:1;
   return _s;
}
Usage:
pawn Код:
if(!empty("test"))
{
   print("full");
}
else
{
   print("empty");
}
&& Sorry if this is wrong section, wasn't exactly sure where to place something like this.
Reply
#2

There is a useful Snippet topic..
Reply
#3

http://forum.sa-mp.com/index.php?topic=12197.0
Reply
#4

Quote:
Originally Posted by [N
BL!nk [DMU - 208.43.133.131:6600] ]
There is a useful Snippet topic..
My bad, I did notice that about 10 hours too late.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)