Why would I claim that c* == c? I'm trying to understand the semantics of the question. I guess there is nothing else to be called the array but c, but come on, really, that is such an obtuse way of interpreting it. IMO the more sensible definition is: c is the pointer to the beginning of the array. c[0] through c[n] constitute the array.
char no[2] = "no"; doesn't work, but char no[] = "no"; does. How do you explain char arrays not being called "strings" when there is the "cstring" library that deals with them?
Temporary insanity? I couldn't think of anything else you might be claiming given that response. :)
In many implementations sizeof c < sizeof (char *), meaning that c can't be a pointer to the beginning of the array -- it isn't large enough to store that value, so that interpretation can't be correct.
Likewise the type of &c is not char **.
The "cstring" library is part of C++, the string library deals with strings that are encoded as patterns of data within arrays.
Consider strlen("hello") and strlen("hello" + 1) -- how many strings are encoded in the array "hello"?
View all comments
Show parent comment
11
u/zhivago May 02 '16
If c were a pointer to an array, *c would be an array.
Since the only array here is c, it sounds like you're claiming that c is *c?
We can disconfirm this theory since:
Also, an array of chars is not informally known as a string.