I wanted to test strtok with multiple delimeters, and I wrote the code below, but after printing the first token, token takes the delimeter value instead that of the next word in the string.
#include <string.h>
int main(int argc, char *argv[]) {
char sent[]="-This is ?a sentence, with various symbols. I will use strtok to get;;; each word.";
char *token;
printf("%s\n",sent);
token=strtok(sent," -.?;,");
while(token!=NULL){
printf("%s\n",token);
token=(NULL," -.?;,");
}
return 0;
}