NULL in pawn, undefined strtok
#1

pawn Код:
while(str != NULL)
error 017: undefined symbol "NULL"

pawn Код:
idx = strtok(cmdtext, " ");
error 017: undefined symbol "strtok"
Reply
#2

strcmp..
Reply
#3

Quote:
Originally Posted by SomebodyAndMe
Посмотреть сообщение
strcmp..
strcmp compares strings, I have to split string into tokens
Reply
#4

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

pawn Код:
#define NULL ('\0')
Reply
#6

Don't use strcmp + strtok...

Use ZCMD + sscanf
Reply
#7

Quote:
Originally Posted by Sinner
Посмотреть сообщение
pawn Код:
#define NULL ('\0')
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
Reply
#8

you can try this instead of using null, which isn't defined in pawn:
pawn Код:
while(strlen(str))
Reply
#9

Quote:
Originally Posted by xDeadlyBoy
Посмотреть сообщение
you can try this instead of using null, which isn't defined in pawn:
pawn Код:
while(strlen(str))
If you want a server forever hanging, you should use that...
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)