Storing token into array

sir i had tried two ways but both are not working ,what is the problem in doing it.

int main()
{
char s[]=“hi, i am using the, coding blocks course, that is C++”;
char *ch[10];
char t[10];
int i=0;
ch[i++]=strtok(s," ,");
//cout<<*ch;
while(ch!=NULL)
{
ch[i++]=strtok(NULL," ,");
}
for(int i=0;i<5;i++)
cout<<ch[i]<<endl;

}

//way 2:
char s[]=“hi, i am using the, coding blocks course, that is C++”;
char *ch;
char t[10];
int i=0;
ch=strtok(s," ,");
//cout<<*ch;
while(ch!=NULL)
{ cout<<ch<<endl;
t[i]=ch;
i++;
ch=strtok(NULL," ,");
}
for(int i=0;i<strlen(s);i++)
cout<<t[i]<<endl;

There are some minor mistakes
a) The array of pointers ith element has to be compared to NULL in the while loop
b) While printing you have to print the elements until the value in pointer array becomes NULL
ie
for(int i = 0 ; ch[i] != NULL ; i++){ cout << ch[i]<<endl;}

Corrected code

On similar grounds try figuring out the mistakes in code 2.

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.