NULL in pawn, undefined strtok - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: NULL in pawn, undefined strtok (
/showthread.php?tid=364275)
NULL in pawn, undefined strtok -
SEnergy - 30.07.2012
error 017: undefined symbol "NULL"
pawn Код:
idx = strtok(cmdtext, " ");
error 017: undefined symbol "strtok"
Re: NULL in pawn, undefined strtok -
SomebodyAndMe - 30.07.2012
strcmp..
Re: NULL in pawn, undefined strtok -
SEnergy - 30.07.2012
Quote:
Originally Posted by SomebodyAndMe
strcmp..
|
strcmp compares strings, I have to split string into tokens
Re: NULL in pawn, undefined strtok -
SomebodyAndMe - 30.07.2012
You can't use a string as an array, you have to do something like #define blabla "NULL".
Look at the wiki.
https://sampwiki.blast.hk/wiki/Strtok
pawn Код:
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
Re: NULL in pawn, undefined strtok -
Sinner - 30.07.2012
Re: NULL in pawn, undefined strtok -
Jochemd - 30.07.2012
Don't use strcmp + strtok...
Use ZCMD + sscanf
Re: NULL in pawn, undefined strtok -
SEnergy - 30.07.2012
Quote:
Originally Posted by Sinner
|
didnt know that I have to declare my own NULL in pawn O_o thanks!
Quote:
Originally Posted by Jochemd
Don't use strcmp + strtok...
Use ZCMD + sscanf
|
I've never ever used those before :X but I guess I'll have to
Re: NULL in pawn, undefined strtok -
xDeadlyBoy - 30.07.2012
you can try this instead of using null, which isn't defined in pawn:
Re: NULL in pawn, undefined strtok -
Jochemd - 30.07.2012
Quote:
Originally Posted by xDeadlyBoy
you can try this instead of using null, which isn't defined in pawn:
|
If you want a server forever hanging, you should use that...