怎么存入文档都是乱码啊,,我不是以二进制存的啊
#include"stdio.h"#include<stdlib.h>
#include<ctype.h>
#define N 3
struct score
{
int chinese;
int math;
int english;
int comin;
int 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("%lf %lf %lf %lf %lf",&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);
}