1, the rule of reference:
A. When a level two pointer acts as a function parameter, it is a level two pointer, an array of pointers, and an address of a first-hand pointer.
B. When the array pointer acts as a function parameter, the function argument is a two-dimensional array, and the array pointer
C. When a two-dimensional array is used as a function parameter, the function argument is a two-dimensional array, and the array pointer
D. When an array of pointers is used as a function parameter, it is an array of pointers, a level two pointer, and the address of a first-hand pointer as a function argument.
2. Example verification:
#include <stdio.h> #include <stdlib.h> void fun1 (int **pp) {printf ("fun1\n");} void fun2 (int (*a_p) [5]) {printf ("fun2\n");} void Fun3 (int t_d_a[][5]) {printf ("fun3\n");} void Fun4 (int *p_a[
5]) {printf ("fun4\n");} int main () {int *p_a[5]; pointer array int **pp = NULL; Second-level pointer int *p = NULL; First level pointer int t_d_a[5][5]; Two-dimensional array int a[5]; one-dimensional array int (*a_p) [5] = &a;
Array pointer fun1 (P_A);
FUN1 (PP);
FUN1 (&P);
FUN1 (t_d_a);
FUN1 (a_p);
printf ("\ n");
Fun2 (p_a);
FUN2 (PP);
Fun2 (&P);
Fun2 (t_d_a);
Fun2 (a_p);
printf ("\ n");
FUN3 (p_a);
FUN3 (PP);
FUN3 (&P);
FUN3 (t_d_a);
FUN3 (a_p);
printf ("\ n");
Fun4 (p_a);
FUN4 (PP);
Fun4 (&P);
Fun4 (t_d_a);
Fun4 (a_p);
printf ("\ n");
System ("pause");
return 0; }
The above code I let go of any of the comments, and the error is not compatible with the type of the formal participation argument.
PS: Debug environment is vs2013