c语言函数指针

c语言中 声明类型的解读可以 用右左规则:

The right-left rule: Start reading the declaration from theinnermost parentheses,

go right, and then go left. When youencounter parentheses, the direction should be reversed.

Onceeverything in the parentheses has been parsed, jump out of it.

Continue till the whole declaration has been parsed.

从最里面的圆括号开始读, 先向右,在向左; 当遇到圆括号后,返回;  圆括号内容都被解析后,跳出,然后继续解析;

int  *dec[];

dec是一个数组变量,数组内元素是int*类型;

int (*dec)[] ;

dec是指针,指向整形类型数组;

int (*com) ();

com是函数类型指针,返回值是int;

int (*com[5])(int *p);

com是5个元素数组,数组内元素类型是指针,指针类型为返回int值的函数;

int (*(*com)(int *p))[5];

com是指针类型, 指向的是函数类型,函数的返回值是指针类型, 这个指针指向5个元素的整形数组;

总结下: com是函数类型指针; 函数反回值是 一个 指向有5个元素的数组的指针;

为了使声明容易读:用typedef

typedef  int (*Pa)[5];

Pa (*com)(int *p);    


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值