0

I am working on a project that requires me to recive data from a network application. After I recive the data I'm suppose to break it up. Now I know of a way to sorta do that by using "tokens" and strtok (if you don't know strok breaks up a string by delminating character i.e. \n ). My problem is that I need to do it twice. Once for "\n" and once for "\t", but my program crashes when I use strtok a second time. For example:

tokenPtr = strtok (m_pBuf , "\n");
	while ( tokenPtr != NULL )
	{
		temp[i] = tokenPtr;
		tokenPtr = strtok(NULL, "\n");
		i++;
	}

This works, but doesn't give to resluts needed. I need to break it further up, however:

tokenPtr = strtok (m_pBuf , "\n");
	while ( tokenPtr != NULL )
	{
		temp[i] = tokenPtr;
		tokenPtr = strtok(NULL, "\n");
		i++;
	}
	while ( count <= i )
	{
		tokenPtr = strtok (temp[count] , "\t");
		while ( tokenPtr != NULL )
		{
			temp2[j] = tokenPtr;
			tokenPtr = strtok(NULL, "\t");
			j++;
		}
		count++;
		tokenPtr = "";
	}

crashes the program.
Any ideas on how to work this out?

2
Contributors
2
Replies
3
Views
12 Years
Discussion Span
Last Post by atrusmre
0

WOW!!! Thank you!!! That worked exactly like I wanted!! :) Thank you so much. (In answer to your question, I didn't know I could do that and make it work right. It doesn't seem like it would, but it does!) Thank you again!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.