i am using the following code to tokenize a character array

for(int i = 1; i <= count+1; i++)
name[i] = strtok(NULL, "("); 

type[i] = strtok(NULL, ")");

b << type[i] << " " << name[i]; b << ";"<<endl;

cout << type[i] << name[i] << endl;


however in the name character string an unwanted "," also appears, that is not needed, please suggest a way to remove the "," from the characterstring, thanks

however in the name character string an unwanted "," also appears

Perhaps you should post an example of the string being tokenized and explain exactly what parts you need. :icon_rolleyes:

I do not understand why you are trying to tokinize NULL pointer.

Then perhaps you should read the link you posted. strtok keeps an internal state of the string. To continue using that state (and thus retrieve further tokens from the same string) rather than refresh it with a new string, subsequent calls should be passed a null pointer as the first argument.

@Demigoddess Narue:
It is true that I do not know the strtok, probably read about it around 30 years ago. However, the code posted does not have any other value than NULL inputed to the function, so the fragment is difficult to understand, even to Your Divinity, like you posted.

Maybe I should stay in Forum I belong and leave these low lands as your realm:P (Happy Mother's Day BTW :*)