- 论坛徽章:
- 12
|
问个菜题,纯C中,如何在定义结构体时
谢谢各位!
我在Linux上
gcc version 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)
源文件 t.c
- #include <stdio.h>;
- #include <string.h>;
- #include <stdlib.h>;
- int main()
- {
- typedef struct _Stu{
- char name[32]:"asdf";
- int age:1;
- }Stu, *PStu;
- Stu zhang;
- printf("%s\n", zhang.name);
- printf("%d\n", zhang.age);
- }
复制代码
编译:$ gcc t.c
- :! gcc t.c
- t.c: In function `main':
- t.c:8: error: bit-field `name' width not an integer constant
- t.c:14: error: cannot take address of bit-field `name'
- Shell 已返回1
复制代码
说我那个地方的宽度不是一个整数的常量?郁闷 |
|