Hi,
this is something everyone knows, but i HATE the usual implementation, so i made one, it is faster btw (takes about 2/3 of the original time)
Код:
stock strtok(const source[], &index, dest[], separator = ' ')
{
new i = 0;
while((dest[i] = source[index]))//while we've not reached the end of the string
{
if(source[index] != separator)//if the separator isn't reached yet
{
index++;//increment the variables
i++;
}
else//on est rendu au sйparateur
{
index++;//we go to the next character (skip the separator)
dest[i] = EOS;//in cas of troubles
break;
}
}
}
have fun :P
use:
Код:
new input[] = "Hello, this is a testing!";
new begin = 5, destination[16];
strtok(input, begin, destination);
print(destination);
instead of:
Код:
new input[] = "Hello, this is a testing!";
new begin = 5, destination[16];
destination = strtok(input, begin);
print(destination);
note: this function is faster and safer, you don't need to worry about the length of an internal string, just care about yours.
edited function to make sure it is safe...
++Sim++