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?