as in code there is a line as
char s=strtok((char)str.c_str()," ");
- in this what is the function of (char*)
- what is the function of c_str() function
- what this is doing in the code
pls explain i have lot of confusion in understanding this code
as in code there is a line as
char s=strtok((char)str.c_str()," ");
pls explain i have lot of confusion in understanding this code
hello @shivamgoel150
c_str() function is used to convert c++ string into c style string.
it returns const char* type pointer but strtok takes char* type pointer thats why we are using (char* ) to explicitly type cast const char* into 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.