Why we used (char *) for typecasting str.c_str( )

In the Question discussed in Strings 05 - Solving a String Challenge, Sir made a function string extractStringAtKey(string str, int key)( ) . In this function sir used strtok which accepts and return character arrays since str is a string we need to first convert this into a character array so to access the underlying character array in string class we used c_str() function and typecasted str.c_str() using (char *) but my question why we need to use that wouldn’t str.c_str() returns a character array itself then why explicitly typecast it to a char

hi @gitansh1,
it return const char*, but expected is char *

that’s y typecasted

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.