问题 单项选择题

以下选项中不能正确把c1定义成结构体变量的是

A.typedef struct
int red:
int green:
int blue;
COLOR;
COLOR c1;

B.struct color c1
int red
int green:
int blue;
;

C.struct color
int red ,
int green :
int blue :
)cl;

D.struct
int red;
int green;
int blue
c1 ;

答案

参考答案:B

解析: 本题考核的知识点是结构体类型定义。结构体类型的定义格式为:
strcut 结构体名
{成虽说明列表};
结构体变量的定义有3种形式:第一种,定义结构体型的同时定义结构体变量,如:strcut 结构体名 {成员说明列表}变量;选项C属于这种情况,故选项C正确:第二种,先定义一个结构体类型,然后使用该类型来定义结构体变量,如:strcut student{成员说明列表}:student 变量;选项A属于这种情况,故选项A正确;第三种,定义一个无名称的结构体类型的同时定义结构体变量,如:strcut student{成员说明列表}变量;选项D属于这种情况,故选项D正确.所以,4个选项中选项B符合题意。

选择题
多项选择题