C指针数组、数组指针与函数指针的应用

此次案例注重讲解:指针数组、数组指针以及函数指针的应用。有一点难度,需要只需琢磨!

代码如下:

1 /*
2 @author zengweilin
3 @2011/6/16 指针的应用举例
4 @notice:声明在C语言函数中只能放在开头,切记!!!
5 */
6 #include "stdio.h"
7 #include "stdlib.h"
8 /*返回指向函数的指针*/
9 int* fun(int a){
10 return &a;
11 }
12 int main(){
13 /*<1>*/
14 int *a=fun(10);
15 /*<2>*/
16 int* m[10];
17 int n=15;
18 /*<3>*/
19 int (*b)[10];
20 int c[10]={1,2,3,4,5,6,7,8,9};
21 /*<1> 指向函数的指针*/
22 printf("%d\n",*a);
23 /*<2> 含有是个指针的数组*/
24 m[0]=&n;
25 printf("%d\n",*m[0]);
26 /*<3> 指向含有是个整型数组的指针*/
27 b=&c;
28 printf("%d\n",*(*b+5));
29 exit(0);
30 }
 

posted @ 2011-06-19 23:14  KISS's blog  阅读(1147)  评论(5编辑  收藏  举报