String tokenizer

strtok acceps char* as its first argument then why name of character array is given as first argument instead of pointer eg-
char s[ ] = “Hello world”;

char* ptr = strtok( s, " ");

Here we have given s which is the name of the array and it is not of the type char*, so why can we use it?

hi @abhayg1602 its a character array, so we can use a character pointer.

But their datatype is different

@abhayg1602 they are both of char datatype, how are they different?
character arrays are stored at contigous memory locations, and if you have an array arr, and you do cout << arr this will give you the address of the first element of the array. This means that arrays also store the addresses, just like pointers do.
In dynamic memory allocation also, we use pointers to make use of the heap memory. I think you are getting confused about this thing, but they can be used interchangeablly in some cases. Do read about pointers and arrays in detail if this continues to confuse you, and let me know if there’s anything in particular that is bothering you.

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.