Strings (Sort the string) -- Doubt 1

in line -5
str s = strtok (( char )str.c_str() , " ");
what is the use of c_ str function…also why have we type casted str using (char*) .

first see the definition of both the functions

char * strtok ( char * str, const char * delimiters );

const char* c_str() const;

str is string but inside strtok we have to pass char*
so we use c_str() function to convert string to char*
but it return (const char*) not (char*)
so we again type cast it 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.