in this video sir converted string to char by
(char*)str.c_str();
please explain me the complete meaning of this
Can you explain typecasting here?
Hey @sid.rajput23 c_str function converts c++ string(which is essentially a null terminated array of bytes) to const char * but strtok wants char * ,So what we are doing is explicitly typecasting const char * to char *
can you elaborate with example?
i think you are saying that by ββc_strββ we can convert string str to a CONSTANT char type pointer
and
by typing (char*) in front of it makes it to a char pointer
Yes i mean this
so if you will not typecast it, it will give us an error.
1 Like