今天在一个库头文件中看到类似于“typedef const int * const * SIZE”的这种写法,看了半天才明白。
typedef const int * const * SIZE 是把SIZE定义为常量指针,即const * SIZE等价于const int * ,SIZE为指向常量的指针类型别名
#include <stdio.h>
typedef const int * const * SIZE;
int main()
{
const int a = 5;
SIZE b = (SIZE)&a;
printf("value is %d\n", *(int *)b);
return (0);
}
本文解析了C语言中复杂的类型定义,如typedef const int *const *SIZE,并提供了示例代码来展示如何使用这种类型的变量。通过实例解释了如何声明指向常量的指针类型。
1487

被折叠的 条评论
为什么被折叠?



