What id the error in the code,

#include
#include
using namespace std;

//char *strtok(char *, char *delimiters)
//returns a token on each subsequent call
//on the first call function should be passed with string argument for ‘s’
//on subsequent calls we should pass the string argument as null

int main()
{
char s[100] = “Today is a rainy day”;

char *ptr = strtok(s, " ");
cout << ptr << endl;


while(ptr != NULL)
{	
	ptr = strtok(NULL, " "); // maintain the a static variable
	cout << ptr << endl;
}

cout << endl;
char s1[100] = "Today, is a rainy, day";

char *ptr1 = strtok(s1, ",");
cout << ptr1 << endl;


while(ptr1 != NULL)
{	
	ptr1 = strtok(NULL, ","); // maintain the a static variable
	cout << ptr1 << endl;
}
return 0;

}

/*
Output: (when I run the code I am getting this outpu)

Today
is
a
rainy
day

the correct output should be

Today
is
a
rainy
day

Today
is a rainy
day

*/

Please share your code by saving it on ide.codingblocks.com

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.