一道C语言题...求高手帮帮

来源:百度知道 编辑:UC知道 时间:2024/05/24 21:09:15
(49) 若程序中有下面的说明和定义
struct abc
{int x;char y;}
struct abc s1,s2;
则会发生的情况是
A) 编译出错 B) 程序将顺利编译`连接` 执行
C) 能顺利通过编译`连接`但不能执行 D) 能顺利通过编译` 但连接出错
选什么??答案是A 可里面的定义没错啊...为什么选A?

1、如果是先定义结构体,在初始化结构体变量需要在结构体后面加分号(;)
struct abc
{
int x;
char y;
};
struct abc s1,s2;

2、如果在定义的时候初始化结构体变量,可以这样写:
struct
{int x;char y;}s1,s2;

struct abc
{int x;char y;}

结尾缺少分号,应为:

struct abc
{int x;char y;};

结构定义格式错
struct
{
...
}; //大括号最后得有分号

struct
{int x;char y;}s1,s2;