识别复杂变量的声明
时间:2010-03-29 来源:liuyuanyang
/* 1. */ void * (*(*fp1)(int)) [10];
/* 2. */ float (*(*fp2)(int, int, float)) (int); /* 3. */ typedef double (*(*(*fp3)())[10]) ();
fp3 a; /* 4. */ int (*(*f4())[10]) (); |
Number 1 says “fp1 is a pointer to a function that takes an integer argumnet and returns a pointer to an array of 10 void pointers.”
Number 2 says “fp1 is a pointer to a function that takes three arguments(int, int, and float) and returns a pointer to a function that takes an integer argument and returns a flaot.”
Number 3 says “an fp3 is a pointer to a function that takes no arguments and returns a pointer to an array of 10 pointers to functions thant take no arguments and return doubles.”
Number 4 says “f4 is a function that returns a pointer to an array of 10 pointers to functions that returns integers.”
第4个声明的是一个函数,这个函数没有参数,返回一个指针p1
int (*(*f4())[10]) ();
int (*(*p1)[10]) ();
int (* p2 [10]) (); |
p1 指向指针数组,大小为10, 每个元素指向一个没有参数,返回值为int的函数.