1, comparison point, * point,&; Point out the difference between the three.
For int * point;
Point: is a pointer variable whose content is the address quantity.
*point: it is the target variable of the pointer variable, that is, the variable pointed by the pointer, and its content is data.
& ampPoint: refers to the storage address occupied by the pointer variable itself.
2. Pointers and arrays
When accessing data in memory with pointer and array name, their expressions are equivalent, because they are both address quantities.
The array name represents the first address of the whole array, which can be regarded as a pointer to a fixed address and cannot be assigned.
The array name does not need to be given an initial value, but the pointer must be given an initial value before use.
3. Character pointers and strings
The string is an array of characters and ends with "\ 0". When the printf function outputs characters in %s format, it starts at the given address and ends when it encounters the first' \ 0' character.
Initializing a character pointer is to assign the first address of the string to the pointer.
4. Pointer function
A pointer function is a function whose return value is a pointer (address).
5, multistage pointer
Pointer-to-pointer (**p) is a secondary pointer, and pointer-to-pointer (***p) is a tertiary pointer.
Multilevel pointers are similar to indirect addressing.
6. Pointer to function
The function name in C language represents the first address of the function, that is, the address of the group where the function is executed.
Definition form: [storage type] [data type identifier] (* pointer variable name to function) ();
For example: int(* fun)(); (); //pointer to the function, int * fun (); //Pointer function, note that (* fun) brackets cannot be less.
7. Dynamic pointer
Dynamic allocation is best used when large memory is needed.
Use malloc function: void * malloc(size_t size).
Example:
int * pn = malloc( 10 * sizeof(int));
double * PD = malloc( 10 * sizeof(double));