char *ptr=strtok(s," ");
cout<<ptr<<endl;
Also why next time when we called strtok again we didn’t use a pointer symbol(*)
ptr=strtok(NULL," ")
cout<<ptr<<endl;
And why printing value as well we are not using (*) pointer symbol?
char *ptr=strtok(s," ");
cout<<ptr<<endl;
Also why next time when we called strtok again we didn’t use a pointer symbol(*)
ptr=strtok(NULL," ")
cout<<ptr<<endl;
And why printing value as well we are not using (*) pointer symbol?
in this statement we are declaring the pointer so we have to write char * ptr
but after declaration we can use ptr now so here
we directly use it
this is same as any other data type
once you declare a variable int a then next time you didn’t write int a=10;
you just write a=10;
while printing the character array you have to just write cout<<ptr;
if you write cout<< *ptr then it will only print the value of ptr[0]
because ptr contains only the address of first element of array
it is the functionality of cout which is print the whole string while writing cout<<ptr; in case of character array
please watch the pointer videos to understand better
if you want to ask something about this feel free to ask
i hope this helps
if yes show your response with
and don’t forgot to mark doubt as resolved