C语言读写文件的问题
#include<stdio.h>struct STUDENT
{
int num;
char name[20];
char sex[10];
char address[30];
int phone;
}Student[3];
int main()
{ FILE *fp;
int i;
printf("请输入学号,姓名,性别,地址,电话:\n");
for(i = 0;i < 3;i++)
{
scanf("%d%s%s%s%d",&Student[i].num,Student[i].name,Student[i].sex,Student[i].address,&Student[i].phone);
printf("\n");
}
fp = fopen("student.txt","w");
fwrite(&Student,sizeof(struct STUDENT),3,fp);
return 0;
}
我想输入3名同学的信息,写入student.txt文件中,为什么打开student.txt会有乱码?