Why are pointers to arrays of char
s (ie. string
s) written as below:
char *path
Instead of:
char *path[]
or something like that?
How could I create a pointer to a char
and not a string
?
char *path
is not a pointer to a string, it is a pointer to a char
.
It may be the case that char *path
semantically points to a "string", but that is just in the interpretation of the data.
In c, strings often use char *
, but only under the assumption that the pointer is to the first character of the string, and the other characters are subsequent in memory until you reach a null terminator. That does not change the fact that it is just a pointer to a character.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With