程序可以运行,可以在磁盘中存入内容,但是存入磁盘中的内容与我输入的内容不太一样。为什么?
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct student
{
char name[10];
int number;
int age;
char address[20];
}a[3];
int main()
{
int i=0;
FILE *fp;
for(i=0;i<3;i++)
scanf( "%s%d%d%s",a[i].name, &a[i].number, &a[i].age, a[i].address );
if( ( fp = fopen ( "d:\\a.txt" , "w" ) ) == NULL)
{
printf("打开文件失败\n");
exit(1);
}
fwrite( a, sizeof( struct student ), 3, fp );
fclose( fp );
return 0;
}