[C Language] Data Structure-preparation knowledge pointer and preparation pointer
All greatness comes from a brave start
Data structure preparation
Pointer
1. pointer: it is the soul of C language, pointer = address
Address: Number of the memory unit
Pointer variable: the variable that stores the memory unit address
Int * p; // p is a pointer variable. int * indicates that the p variable can only store the address of the int type variable and cannot store other types.
Int I = 10;
P = & I
The two operations are detailed:
1) p stores the I address, so we say p points
2) p and I are two completely different variables. modifying any one of them will not affect the other.
3) p points to I, * p is the I variable itself. More vividly, all the places where * p appears can be changed to I
2. No matter how many bytes the pointing address occupies, all pointer variables only occupy 4 bytes, and the first byte address represents the address of the entire variable.
Pointers and functions
The variable in the function is a local variable. If the parameter is a pointer, you can modify the external variable.
Pointer and array
Int a [5] = {1, 2, 3, 4, 5}
A is a pointer that is always bright and stores the address of the first element of the one-dimensional array. Its value cannot be changed. The name of the one-dimensional array points to the first element of the array.
A [I] <=> * (a + I)