C 语言 达人进

来源:百度知道 编辑:UC知道 时间:2024/06/14 16:45:00
//student.h头文件
typedef struct
{
long Sno;
char Sname[10];
float Chinese;
float Math;
float English;
float Cpro;
float Total;
float aver;
}student;

#include<stdio.h>
#include"student.h"
main()
{
student Temp;
printf("When you want to end,press enter #\n");
printf("Sno:\tSname:\tChinese:\tMath:\tEnglish:\tCpro\t\n");
scanf("%ld\t%ls\t%f\t%f\t%f\t%f",&Temp.Sno,Temp.Sname,&Temp.Chinese,&Temp.Math,&Temp.English,&Temp.Cpro);
printf("%d\t%s\t%f\t%f\t%f\t%f",Temp.Sno,Temp.Sname,Temp.Chinese,Temp.Math,Temp.English,Temp.Cpro);
getch();
}
程序可以编译通过
数据的接收老是在Sname这里出错
找了好久不知道是哪里有问题
麻烦达人帮忙
楼下两位所说的都不是问题

有达人能帮我运行一下这个程序的不 万分感谢

2楼的达人 你用的是VC吧? VC是可以通过

scanf("%ld\t%ls\t%f\t%f\t%f\t%f",&Temp.Sno,Temp.Sname,&Temp.Chinese,&Temp.Math,&Temp.English,&Temp.Cpro);
Temp.Sname前面少了一个&

//student.h头文件
typedef struct
{
long Sno;
char Sname[10];
float Chinese;
float Math;
float English;
float Cpro;
float Total;
float aver;
}student;

#include<stdio.h>
#include"student.h"
main()
{
student Temp;
printf("When you want to end,press enter #\n");
printf("Sno:\tSname:\tChinese:\tMath:\tEnglish:\tCpro\t\n");
scanf("%ld\t%ls\t%f\t%f\t%f\t%f",&Temp.Sno,Temp.Sname,&Temp.Chinese,&Temp.Math,&Temp.English,&Temp.Cpro);
printf("%d\t%s\t%f\t%f\t%f\t%f",Temp.Sno,Temp.Sname,Temp.Chinese,Temp.Math,Temp.English,Temp.Cpro);
getch();