I am using two delimiter inside main() but output is printing only for first delimiter

First I used delimiter as space, its working fine. Next, I used delimiter as a (,) comma just after that. But the output is showing only for space delimiter. Here is my code:

char s[100]= “Today is a rainy day”;
char *ptr = strtok(s," ");
cout<<ptr<<endl;

while(ptr!=NULL){
	ptr=strtok(NULL," ");
	cout<<ptr<<endl;
}

char s1[100]= "Today, is a rainy, day";
char *ptr1 = strtok(s1,",");
cout<<ptr1<<endl;

while(ptr1!=NULL){
	ptr1=strtok(NULL,",");
	cout<<ptr1<<endl;
}

Hey @ankitkaushal please share your code using ide.codingblocks.com , if you don’t know how to do it. You can also ask me that.

Sir here is my code : https://ide.codingblocks.com/s/383753

You can’t use strtok in main function by different ways. Either make a function like prateek bhaiya did in his video and give it as an argument. See this have not used your first while loop and your second while loop gets executed. Do it by making another function

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.