why we did (char*)s instead of s simply in
char *s=strtok((char *)str.c_str()," ");
and what does c.str() do
String tokenization
hello @tejuschaturvedi0
c_str() is a function that converts c++ string into char array(c type string) and return its base address as( const char *).
now look at the declaration of strtok.

here it takes char * type pointer but we have const char * pointer
so first we need to explicitly convert const char * to char *
thats the reason why we have (char*) str.c_str()
char *s = strtok( (char * ) str.c_str() , " ");
I understood the c_str() but I am still confused in const char*. And char*.

look at the return type of c_str function.
it const char * .
right?
and what strtok function takes it char * hence we are explicitly converting const char * to char *
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.