int * ( * ( * (*abc)() ) [6] ) ( )
解读:解读顺序,红->橙->绿->黑
1.红色部分为 函数指针
2.橙色部分为 数组指针
3.绿色部分为 函数指针
4.黑色部分为 返回类型为int*型
综合:指向《返回值为“ 指向 ‘返回值为int型指针的函数指针’ 的数组指针 ”》类型 的函数指针
#include <stdio.h>
typedef int *(*(*(*abc)())[6])();
typedef int* (*p)();//从最里面的类型开始,也就是黑色与绿色
typedef p (*pt)[6];//接着分解橙色
typedef pt (*ppt)();//最后分解红色
int* func()
{
int a = 88;
int *point;
point = &a;
return point;
}
pt func_2()
{
p arry[6] = { &func };
pt point_arry = &arry;
return point_arry;
}
void main()
{
ppt point;
point = func_2;
printf( "%d\n", *(**point())() );//结果为88
abc test;
test = func_2;
printf( "%d\n", *(**test())() );//结果也是88,说明使用typede分解正确
getchar();
}
int (* (*abc)() )[6]
解读:解读顺序,红->橙->黑
1.红色部分为 函数指针
2.橙色部分为 数组指针
3.黑色部分为 返回类型为int型
综合:指向《 返回值为int型数组指针 》类型 的函数指针
#include <stdio.h>
typedef int (*p)[6];//先是黑色与橙色
typedef p (*pt)();//红色
typedef int (*(*abc)())[6];
p func()
{
int arry[2][6] = { { 1, 2, 3, 4, 5, 6 },{ 7, 8, 9, 10, 11, 12 }};
p point;
point = arry;
return arry;
}
void main()
{
pt point_func;
abc point_func_2;
point_func = func;
point_func_2 = func;
printf( "%d\n", **point_func() );
printf( "%d\n", **point_func_2() );//证明pt和abc的类型正确
// printf( "%d\n", **(func() + 1 ));
getchar();
}
int (** (*abc)() )();
解读:解读顺序,红->橙->黑
1.红色部分为 函数指针
2.橙色部分为 指向函数指针的指针
3.黑色部分为 返回类型为int型
综合:指向《 返回值为int型 指向函数指针的指针 》类型 的函数指针
#include <stdio.h>
/*typedef int (**(*abc)())();
typedef int (**p)();//int的函数指针的指针
typedef p (*ppt)();
abc 的类型与 ppt的类型相同
*/
typedef int (*p)();
typedef int (**pt)();//分解橙色与黑色部分
typedef pt (*ppt)();//分解红色部分
int max()
{
int a = 32;
return a;
}
pt func()
{
p point_max;//函数指针
pt p_p_max;//指向函数指针的指针
point_max = &max;
p_p_max = &point_max;
return p_p_max;
}
void main()
{
ppt k;//指向的函数具有“ 返回值为int的函数指针的指针”
k = &func;
printf( "%d\n", (**((*k)()))() );//“(*k)()”==>func(),(**((*k)()))() )==>max()
getchar();
}
int *( *abc ) [6]
解读:解读顺序,红->橙->黑
1.红色部分为 指针
2.橙色部分为 指针数组
3.黑色部分为 类型为int型
综合:指向《 int型 指针数组 》类型 的指针
#include <stdio.h>
typedef int *p[6];//分解黑色与橙色
typedef p *pt; //分解红色
typedef int *(*abc)[6];
void main()
{
int a = 88;
int *k = &a;
p point_arry = { k };
pt point = &point_arry;
printf( "%d\n", ***point );
abc test = &point_arry;
printf( "%d\n", ***test );
getchar();
}
int * (* abc() )()
解读:解读顺序,红->橙->黑
1.红色部分为 函数
2.橙色部分为 函数指针
3.黑色部分为 类型为in*t型
综合:返回 《 int*型的函数指针 》的函数
#include <stdio.h>
typedef int *(*p)();//返回值为int型指针的函数指针
int* mm()
{
int *p ;
int a = 88;
p = &a;
return p;
}
int *(*abc())()//返回值为“返回值为int型指针的函数指针”
{
p a;
a = &mm;
return a;
}
void main()
{
printf( "%d\n", *((*abc())()) );//(*abc())得到mm的地址,((*abc())())等价于mm(),*((*abc())())取到mm()这个地址里面的值
getchar();
}
int **( *abc[6] )()
解读:解读顺序,红->橙->黑
1.红色部分为 指针数组
2.橙色部分为 指向函数指针的指针
3.黑色部分为 类型为int型
综合:指向 《 int型指向函数指针的指针 》的指针数组
#include <stdio.h>
typedef int** p();//先分解橙色与黑色
typedef p ( *test[6] );//分解红色
typedef int **( * abc[6] )();
int **func()
{
int a = 88;
int *p = &a;
int **ppt = &p;
return ppt;
}
void main()
{
test a;
a[0] = func;
// printf( "%d\n", **func());
printf( "%d\n", **(a[0]()));
getchar();
}