#include <stdio.h>
#include <stdlib.h>
#pragma warning(disable:4996)//
#define NULL 0
#define SIZE 2
struct student
{
char name[10];
int num;
int age;
}stud[SIZE];
void save()
{
FILE *fp;
int i;
if((fp=fopen("stulist.txt","wb"))==NULL)
{printf("cannot open the file stulist\n");exit(0);}
for(i=0;i<SIZE;i++)
if(fwrite(&stud[i],sizeof(struct student),1,fp)!=1)printf("error\n");
fclose(fp);
}
void main(int argc,char *argv[])
{
int i=0;
while(i<SIZE)
{
scanf("%s%d%d",&stud[i].name,&stud[i].age,&stud[i].num);
i++;
}
save();
}
上述从终端输入以后,在文件中是一堆乱码,跟终端输入的不一致,请问是哪个地出问题了啊。