#include?<stdio.h>
int?main(){
struct?student{
?int?num;
?char?name[50];
?float?score;
}stu1,stu2,stu3;
stu1.num=1;
strcpy(stu1.name,"Jihong?Liu");
stu1.score=100;
stu2.num=2;
strcpy(stu2.name,"Wei?Liu");
stu2.score=67;
struct?student?stu3={3,"San?Zhang",80};
printf("stu1:\nname:%s;num:%d;score:%.1f\n",stu1.name,stu1.num,stu1.score);
printf("stu2:\nname:%s;num:%d;score:%.1f\n",stu2.name,stu2.num,stu2.score);
printf("stu3:\nname:%s;num:%d;score:%.1f\n",stu3.name,stu3.num,stu3.score);
return?0;
}
2 回答


望遠(yuǎn)
TA貢獻(xiàn)1017條經(jīng)驗(yàn) 獲得超1032個(gè)贊
stu3數(shù)據(jù)重復(fù)定義
未導(dǎo)入string.h
C語言數(shù)據(jù)定義只能在函數(shù)開頭處定義
- 2 回答
- 0 關(guān)注
- 2506 瀏覽
添加回答
舉報(bào)
0/150
提交
取消