【正确答案】:定义结构体表示学生档案信息。 #include
从键盘上输入全班学生的档案信息,并存储在硬盘文件“C:\test\class.dat"中。
- 2024-11-06 17:17:46
- 高级语言程序设计(13013)
从键盘上输入全班学生的档案信息,并存储在硬盘文件“C:\test\class.dat"中。
【正确答案】:定义结构体表示学生档案信息。 #include
main()
{
struct STD
{
char name[20];
int No;
char Sex;
float Score;
};
struct STD Student;
shar bEnd;
FILE*fp;
fp=fopen("C:\test\class.dat","W");
if(fp==NULL)
prinff("Can 't open the Class.dat");
else
{
while(1)
{
prinff(Continue(C)or Exit(E)?");
scanf("%c",&bEnd);
ijf(bEnd="E")break;
else
{
prinff("Please input Name,No,Sex,Score\n");
scanf("% s% d% c% f", &Student.name, &Student.No, &Student.Sex,
&Student.Score);
fwrite(&student,sizeof(struct STD),1,fp);
}
}
}
【正确答案】:定义结构体表示学生档案信息。 #include