这是我的C程序
#include <stdio.h> struct xyx { int x; int y; char c; char str[20]; int arr[2]; }; int main(void) { struct xyz a; a.x = 100; printf("%d\n",a.x); return 0; }
这是我得到的错误….
按ENTER或键入命令继续
13structtest.c: In function ‘main’: 13structtest.c:13:13: error: storage size of ‘a’ isn’t known 13structtest.c:13:13: warning: unused variable ‘a’ [-Wunused-variable]
解决方法
你的结构称为struct xyx,但是一个是struct xyz.
Once you fix that,the output is
100
.
#include <stdio.h> struct xyx { int x; int y; char c; char str[20]; int arr[2]; }; int main(void) { struct xyx a; a.x = 100; printf("%d\n",a.x); return 0; }