Solving a string challenge

why we use c_str( )?

it is use to convert string into character array
it is required because strtok() accepts only character array

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

documentation

but we r also typecasting it by using (char*)
eg - (char *)string.c_str()

this is because c_str() give const char* but we want char* so that why we type cast it

const char* c_str() const;

documentation