Chapter 4 shocking fact: arrays and pointers are different
Many C-language books are vague about the time when arrays and pointers are the same and when they are different. The topic that should be elaborated on here is just a few things;
A declaration is equivalent to a general declaration: it describes the object created elsewhere rather than itself;
Definition is equivalent to a special declaration: it allocates memory for the object;
X = y;
In this context, the meaning of symbol X is the address represented by X, and the meaning of symbol Y is the content of the address represented by Y;
The array name must be left but not left;
# Include <stdio. h> int main () {char * P = "012345"; char a [19] = "01234"; // float * Pi = 3.14; printf ("% C ", P [1]); // P [1] = CH; printf ("% C", a [1]); A [1] = 'a '; printf ("% C", a [1]); Return 0 ;};
AboveCodeVerification: 1. Only string constants can be initialized in the definition; 2. string constants with char * are defined as read-only; 3. string constants defined with Char A [] can be modified;