这个程序有错误吗?

dongzhilin 2004-02-11 01:06:33
#include <stdio.h>
#include <string.h>

struct Stu
{
char name[20];
double math;
double chinese;
double english;
};

main()
{
struct Stu stu[10];
int i;
char nm[20];
double ma;
double ch;
double en;
printf("Please Enter student's name,math,chinese,english\n");
for (i=0; i<10; i++)
{
/* scanf("%s %f %f %f",&nm,&ma,&ch,&en);*/
scanf("%s",&nm);
scanf("%f",&ma);
scanf("%f",&ch);
scanf("%f",&en);
printf("%s:%f,%f,%f",nm,ma,ch,en);
strcpy(stu[i].name,nm);
stu[i].math=ma;
stu[i].chinese=ch;
stu[i].english=en;
printf("ok\n");
printf("%s:%f,%f,%f",stu[i].name,stu[i].math,stu[i].chinese,stu[i].english);
printf("\n");
}
printf("Print scores:\n");
printf("name\t\tmath\tchinese\tenglish\n");
for (i=0; i<10; i++)
{
printf("%s\t\t%f\t%f\t%f\n",stu[i].name,stu[i].math,stu[i].chinese,
stu[i].english);
}
}

我用devcpp编译,其中scanf到nm正确,但scanf到nm,ch,en则不行,请大家指点一下
...全文
15 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复

69,382

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧