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;
[Cpp]
# 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;
};
Code verification: 1. Only a String constant can be initialized in the definition; 2. a String constant with char * is defined as read-only; 3. a String constant defined with char a [] can be modified;
From CodeBlog