How exactly we have done typecasting of string into a character array ?
Typecasting of string
str is string but to use strtok we have to pass character array as a parameter
so we are converting string to character array
s=strtok((char*)str.c_str()," ");
str.c_str() this coverts string to const char* but we want only char* hence now we typecast it to char* using
(char*)str.c_str()
now we can pass it to strtok
if you want to explore more you can read about them in documentation
c_str()
if you have more doubts regarding this feel free to ask
i hope this helps
if yes hit a like
: and don’t forgot to mark doubt as resolved 
1 Like