C - 错误:“a"的存储大小未知 [英] C - error: storage size of ‘a’ isn’t known
本文介绍了C - 错误:“a"的存储大小未知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的 C 程序...
#include 结构 xyx {整数 x;输入 y;字符 c;字符 str[20];int arr[2];};int main(void){结构体 xyz a;a.x = 100;printf("%d\n", a.x);返回0;}
这是我得到的错误....
按 ENTER 或输入命令继续
<前>13structtest.c:在函数‘main’中:13structtest.c:13:13: 错误:a"的存储大小未知13structtest.c:13:13:警告:未使用的变量a"[-Wunused-variable] 解决方案
您的结构名为 struct xyx
但 a
的类型为 struct xyz
>.修复后,输出为 100
.
#include 结构 xyx {整数 x;输入 y;字符 c;字符 str[20];int arr[2];};int main(void){结构 xyx a;a.x = 100;printf("%d\n", a.x);返回0;}
This is my C program...
#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;
}
This is the error that I am getting....
Press ENTER or type command to continue
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]
解决方案
Your struct is called struct xyx
but a
is of type 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;
}
这篇关于C - 错误:“a"的存储大小未知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文