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.....

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