Strtok problem
#1

Hai,

I use "dini" inc for my gm. And i didn't introduce strtok into my gm and incs. Then, i tried to add "yrace" fs into my gm, it gave errors like "error 047: array sizes do not match, or destination array is too small". But when i delete "#include <dini>" from my gm, this errors dissapears, "undefineded symbol "strtok"" appears. But i have no strtok introtuce in my dini.inc...

Any ideas?
Reply
#2

Guyz, can you tell me the difference between "strtok(const string[], &index)" and "strtok(const string[], &index,seperator=' ')" ?? sorry for double posting, i need it a lot. If i change "seperator" one with another one, what happens?
Reply
#3

Undefined symbol "strtok" problem solving with:
pawn Код:
stock 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;
}
I prefer using strtok(const string[], &index) because you use it for 2 parts, and with seperator its 3 I think, not sure, and make the size bigger of error 47 line (e.g. if you have
pawn Код:
new string[100];
change it to for example
pawn Код:
new string[200];
Reply
#4

Seperator allows you for where to split the string, if it's empty it'll split at the nearest space, if you put in "|" it's return text from that | to the next |

pawn Код:
strtok("Hey guys how you doing?", 0);
Results in an outcome of "guys"

pawn Код:
strtok("Hey guys how you |doing|", 0, "|");
Results in an outcome of "doing"
Reply
#5

the problem is that Dini use dutils, so.. that's why when you delete "#include <Dini>" appears "undefined simbol strtok".

Please post the line that has this error: "error 047: array sizes do not match, or destination array is too small".

it maybe look something like this "arrayname = strtok(params, Index);" or "arrayname = strtok(cmdtext, idx);" or something like that.
you migth have define the array with a smaller size that it need. check out if you have "new arrayname[256];"
Reply
#6

well, i have fixed it. Changed seperator thing with known strtok. There is no error as pawno grammer, but i hope there will be no errors ingame, too..?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)