#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include<stdio.h>
#include<unistd.h>
#include<string.h>
#include<stdlib.h>
struct Test
{
int a;
char c;
};
int main()
{
FILE *fp;
struct Test data[2] ={100,'a'};
struct Test data2[2];
fp= fopen("./file2","w+");
int n_write = fwrite(&data,sizeof(struct Test),1,fp);
fseek(fp,0,SEEK_SET);
int n_read = fread(&data2,sizeof(struct Test),1,fp);
printf("read %d ,%c\n",data2[0].a,data2[0].c);
fclose(fp);
return 0;
}
结果