函数指针数组指针实例

 1 #include <stdio.h>

 2 #include <string.h>

 3 char * fun1(char * p)

 4 {

 5 printf("%s\n",p);

 6 return p;

 7 }

 8 char * fun2(char * p)

 9 {

10 printf("%s\n",p);

11 return p;

12 }

13 char * fun3(char * p)

14 {

15 printf("%s\n",p);

16 return p;

17 }

18 int main()

19 {

20 char * (*a[3])(char * p);

21 char * (*(*pf)[3])(char * p);

22 pf = &a;

23 a[0] = fun1;

24 a[1] = &fun2;

25 a[2] = &fun3;

26 (*pf)[0]("fun1");

27 (*pf)[1]("fun2");

28 (*pf)[2]("fun3");

29 return 0;

30 }

 

你可能感兴趣的:(函数指针)