demo:
#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 = {100,'a'};
struct Test data2;
fp = fopen("./file1","w+");
fwrite(&data,sizeof(struct Test),1,fp);
fseek(fp,0,SEEK_SET);
fread(&data2,sizeof(struct Test),1,fp);
printf("read %d %c\n",data2.a,data2.c);
fclose(fp);
return 0;
}