They say a string is naturally an array of characters which represents the memory location of its first character: string == &string[0]
Two small clarifications here.
A string is technically not an array of characters. It is defined as "a contiguous sequence of code units terminated by the first zero code unit" Or as RobertS said in comments: "A string can be (and high-probably is) stored in an array, but a string is not an array. A string is just a sequence of characters terminated by the null character. A string isn't an array and an array isn't a string."
If string
is an array and not a pointer, then they will have different types. string
is of type char[]
and &string[0]
is of type char*
. However, if you do the comparison string == &string[0]
then string
will decay to char*
and the expression will evaluate to true.
Related:
Is an array name a pointer?
Can it cause problems to pass the address to an array instead of the array?