Splitting strings using strtok at another character
#1

Hello,

I want to split strings with strtok, not at a space, but on a random character, lets say ",".

Код:
new_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;
}
Works perfectly fine but it still splits strings at spaces too. How can I fix that?
Reply


Messages In This Thread
Splitting strings using strtok at another character - by theRealG - 29.01.2010, 06:04
Re: Splitting strings using strtok at another character - by mansonh - 29.01.2010, 06:09
Re: Splitting strings using strtok at another character - by theRealG - 29.01.2010, 11:49
Re: Splitting strings using strtok at another character - by theRealG - 29.01.2010, 12:27

Forum Jump:


Users browsing this thread: 2 Guest(s)