0

cant understand much
this is the code

{
	char *tok, *str;

	str = calloc (50, sizeof(char));

	tok = strtok(str1, " ");
	while(tok)
	{
		if(strcmp(tok,str2)!=0)
		{
			strcat(str, tok);
			strcat(str, " ");
		}
		tok = strtok(NULL, " ");
	}
	strcpy(str1, str);
	return str;
}

what is the function of while(tok) i cant figure it out...
whats it purpose.....

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Salem
0

It's short for while ( tok != NULL ) NULL being returned by the strtok() call in the loop (at some point).

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.