回复 9楼 新风作浪
#include"stdio.h"
#include<stdlib.h>
#include<ctype.h>
#define N 2
struct score
{
float chinese;
float math;
float english;
float comin;
float basis;
};
struct examin
{
int num;
int identnum;
char wenli[10];
struct score
fen;
};
int main()
{
struct examin te[N];//结构体变量的定义
int i;
FILE * fp;
if((fp=fopen("c://score.txt","w+"))==NULL)
{
printf("can't open file score.txt\n");
exit(0);
}
printf("按顺序输入考号、身份证号、文理科、考试成绩(语文、数学、外语、综合、基本能力):\n");
for(i=0;i<N;i++)
{
printf("输入考生 %d 的信息:",i+1);
scanf("%d",&te[i].num);
scanf("%d",&te[i].identnum);
scanf("%s",te[i].wenli);
scanf("%f %f %f %f %f",&te[i].fen.chinese,&te[i].fen.math,
&te[i].fen.english,&te[i].,&te[i].fen.basis);
}
fwrite(&te,sizeof(struct examin),N,fp);//将N个结构体的变量的内容写入文件
fclose(fp);
}