SA-MP Forums Archive
Strtok problem. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Strtok problem. (/showthread.php?tid=225440)



Strtok problem. - AcId n RaPiD - 13.02.2011

I'm currently editing the lvdm.pwn from SAMP and I'm getting a 'strtok' error. To begin with, I honestly haven't touched the strtok code, and this is the error I get.

Код:
C:\Users\User\Desktop\SAMP Scripting\pawno\lvdm.pwn(929) : error 021: symbol already defined: "strtok"
C:\Users\User\Desktop\SAMP Scripting\pawno\lvdm.pwn(944) : error 047: array sizes do not match, or destination array is too small
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
... and ...

This is the line where the error is occurring.

pawn Код:
strtok(const string[], &index)
{ // line 929
    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; // line 944
}
-..

Any concerns why this is actually occurring?


Re: Strtok problem. - Calgon - 13.02.2011

The function 'strtok' already exists, you do not need to add it again.


Re: Strtok problem. - AcId n RaPiD - 13.02.2011

Well, that is the only Strtok function inserted on the script. Anyways, thanks, it works.


Re: Strtok problem. - Calgon - 13.02.2011

The function is probably already defined in an include that you're using. Includes contain pawn code too.


Re: Strtok problem. - Mean - 13.02.2011

Also, I'd recommend using SSCANF instead of strtok, because strtok is: old, slow, outdated.


Re: Strtok problem. - Calgon - 13.02.2011

His problem was solved, recommending a more efficient method is irrelevant to the topic at hand.

Plus you have practically no idea of what you're talking about and probably wouldn't even be able to point out how to indicate speed differences between the two functions.