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);