1. pointer array and array pointer
(1) int * q [10]; pointer array, which declares an array pointing to 10 integer pointer elements.
(2) int (* p) [10]; array pointer, which declares a pointer pointing to 10 integer arrays.
A pointer array is an array with elements as pointers, while an array pointer is a pointer with elements as pointers to arrays.
2. function pointers and pointer Functions
(1) int (* p) max (int a, int B); function pointer. p indicates a function that points to the parameter type of int, int, And the return value is int, you can assign this type of function to p as the first address.
(2) int * max (int a, int B); pointer function. a function that returns a pointer type is called a pointer function.
3. Use a String constant to initialize the pointer and array
(1) char * p = "gooseberry"; character pointer. The String constant created during pointer Initialization is defined as read-only. If you try to modify this string value through the pointer, the program will have undefined behavior.
(2) char a [] = "gooseberry"; character array, which is the opposite of a pointer. The array initialized by a String constant can be modified. For example, the following statement:
Strncpy (a, "black", 5); change the value of the array to blackberry.
4. Constant pointers and pointer Constants
(1) constant pointer: a pointer to a constant. The content of the pointer to an address cannot be modified.
Const int * pi = & a; or int const * pi. * pi is a constant and * p cannot be used as the left value.
(2) pointer constant: you cannot modify the pointer of an address, but you can modify the content of the address to which it points. In addition, pointer constants must be assigned values at the same time during definition, and pointer constants cannot be released.
Define "int * const pi = & a;". pi is a constant and cannot be operated as the left value. However, indirect access values can be modified, that is, * pi can be modified.
Author xuhongwei0411