#include
typedef struct {
int num;
int age;
}Stu;
int main(void)
{
FILE *fp;
Stu *stu;
Stu *stu1;
stu=(Stu *)malloc(sizeof(Stu));
stu1=(Stu *)malloc(sizeof(Stu));
fp=fopen("11.txt","w+");
stu->num=5;
stu->age=4;
fwrite(stu,sizeof(Stu),1,fp);
fread(stu1,sizeof(Stu),1,fp);
printf("%d\n",stu1->num);
printf("%d\n",stu1->age);
fclose(fp);
return 0;
}


hstking 于 2013-08-11 16:55:31发表:
使用sync函?,?????入到文件中。