A pointer is a special variable. The value stored in it is interpreted as an address in the memory. To understand a pointer, we need to understand four aspects of the pointer: the pointer type, the pointer type, the pointer value, or the memory zone pointed by the pointer, there is also the memory zone occupied by the pointer itself.
Pointer type
From the syntax perspective, you only need to remove the pointer name in the pointer declaration statement, and the rest is the pointer type. This is the type of the pointer. Let's take a look at the type of each pointer in Example 1:
(1) int * ptr; // the pointer type is int *
(2) char * ptr; // the pointer type is char *
(3) int ** ptr; // the pointer type is int **
(4) int (* ptr) [3]; // the pointer type is int (*) [3]
(5) int * (* ptr) [4]; // the pointer type is int * (*) [4]
Type pointed to by pointer
When you access the memory area pointed to by the pointer, the type pointed to by the pointer determines what the compiler will regard the content in the memory area.
In terms of syntax, you only need to remove the pointer name and the pointer declarative * on the left of the name in the pointer declaration statement, and the rest is the type pointed to by the pointer. Example: www.2cto.com
(1) int * ptr; // The Pointer Points to an int type.
(2) char * ptr; // The Pointer Points to a char type.
(3) int ** ptr; // The type pointed to by the pointer is int *
(4) int (* ptr) [3]; // The type pointed to by the pointer is int () [3]
(5) int * (* ptr) [4]; // The type pointed to by the pointer is int * () [4]
The pointer value, or the memory zone or address pointed to by the pointer.
The pointer value is the value stored by the pointer itself. This value will be treated as an address by the compiler rather than a general value. In a 32-bit program, the value of all types of pointers is a 32-bit integer, because the 32-bit program's memory address is all 32-bit long. The memory area pointed to by the pointer starts from the memory address represented by the pointer value, and the length is a memory area of si zeof (type pointed to by the pointer. Later, we will say that the value of a pointer is XX, which means that the pointer points to a memory area with XX as the first address. We will say that a pointer points to a memory area, it is equivalent to saying that the pointer value is the first address of the memory area.
/* Int a = 5;
Int * p = &;
Int ** pp = & p;
Int *** ppp = & pp;
// The value of
Printf ("% d \ n", );
Printf ("% d \ n", * p );
Printf ("% d \ n", ** pp );
Printf ("% d \ n", *** ppp );
// Address of
Printf ("% p \ n", & );
Printf ("% p \ n", p );
Printf ("% p \ n", * pp );
Printf ("% p \ n", ** ppp );
// P address
Printf ("% p \ n", & p );
Printf ("% p \ n", pp );
Printf ("% p \ n", * ppp );*/
Return 0;