#include"stdio.h"
#include"stdlib.h"
struct student
{char name[20];
long num;
char major[20];
int year;
}stu;
void main()
{FILE *fp;
scanf("%s%ld%s%d",stu.name,&stu.num,stu.major,&stu.year);
if((fp=fopen("D:\\1","w+"))==NULL)
{printf("cannot open this file\n");
  exit(0);
  }
  fwrite(&stu,sizeof(struct student),1,fp);
  fclose(fp);
}
为什么在文件里出现了乱码?我要求写入的信息没有完全正确的显示呢?