The most powerful of C language-pointer
Pointers are inseparable from addresses. When we mention pointers, we should think of addresses, because in C language, the value of pointer variables is an address. With this value, it can point to the memory location of the address, you can also use this pointer variable to access the content of the memory location. The method for defining a pointer variable is the same as that of other variables: int * a; char * B ;... here, pointer variable a points to the integer pointer, where the value of a is the address of the first byte of the four bytes of the integer space to which it points; B is a pointer to the struct type, the value of B is the address of this character. Initialize the pointer: int a = 123; int * p = & a; int * pi; p = & a; here the integer variable a is defined, define pointers p and pi. They all point to a. The above two initialization methods both point to. Pointer operation: the process of accessing the address pointed to by a pointer is called indirect access or the unreferenced pointer. Its operator is *. For example, the following definition defines int a = 12; int B; int * p; p = & a; B = * p; defines the pointer p, which points to variable, if you want to assign the value of a to B, you can use the pointer p to unreference the pointer p * p to obtain the content of the address pointed to by p, you can assign the value of a to B. Pointer and array: the value of the array name is a pointer constant, that is, the address of the first element of the array. At this time, it is equivalent to unreferencing the pointer and accessing the array by subscript, we can think that the subscript access operator [] and the quote operator * can be used with each other. Int arr [5] = {1, 2, 3, 4, 5}; the value of arr [0] is 1 * the value of arr is also 1, which is equivalent to * (arr + 0)