Returns the pointer value function.
(1) General Form of functions that return pointer values
Type name * function name (parameter table column)
For example, int * a (int x, int y) calls the pointer returned by function a to point to the integer variable.
(2) small example of pointer Functions
For example, enter a student number and output all the scores of the student.
1 # include <stdio. h> 2 int main () {3 int score [] [4] = {60, 70,}, {56, 23,}, {, 45, 23 }}; 4 int * search (int (* pointer) [4], int n); 5 int * p; 6 int I, k; 7 scanf ("% d ", & k); 8 p = search (score, k); 9 for (I = 0; I <4; I ++) 10 printf ("% d ", * (p + I); 11 printf ("\ n"); 12} 13 14 int * search (int (* pointer) [4], int n) {// pointer is the pointer variable pointing to the one-dimensional array 15 int * pt; 16 pt = * (pointer + n ); // pt is the score [k] [0] address 17 return (pt); 18}
Note the difference between * (pointer + n) and (* pointer + n ).
* (P + n) is the address of the first element of a line.
(* P + n) is the address of the nth element of a two-dimensional array.