Passing string in strtok

we are passing array of characters to the function strtok, but when we pass string which itself is array of characters it is showing error. WHY??

Hi @kartiksinghal06113
string is not just a character array. string is a class which has many functions and other variables in it as well. The character array which stores the data is part of it, it is not the only thing in it. When you pass a string class object to the strtok() , it cannot resolve its call as it is not a character array and strtok() is not defined to take a string class object as an argument.
You can read more about the string class here.

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.