这是我的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]
型
9条答案
按热度按时间w46czmvw1#
您的结构体名为
struct xyx
,但a
的类型为struct xyz
.Once you fix that, the output is100
。字符串
uttx8gqw2#
对于任何有这个问题的人来说,这是一个打字错误。检查你的结构delcerations和结构的拼写
falq053o3#
在这种情况下,用户在定义和用法上犯了错误。如果有人对结构做了
typedef
,那么应该使用相同的结构,而不使用struct
,下面是示例。字符串
在函数中使用时
型
l2osamch4#
你把结构体定义为xyx,但你试图创建一个名为xyz的结构体。
qlckcl4x5#
像这样说:
struct xyx a;
svmlkihl6#
更正错别字
字符串
到
型
你可以试试typedef,easy to b
rqqzpn5f7#
你将结构体定义为
xyx
,但是在main中,你使用了struct xyz a;
,这只会创建一个不同命名的结构体的前向声明。尝试使用
xyx a;
而不是这一行。bvuwiixz8#
我通过纠正代码中的一个简单错误解决了我的问题。
list_t new_end_code
声明带来了错误。它应该是,字符串
dbf7pr2w9#
1.在main函数之前解构结构体。
1.如果变量名有拼写错误,