#include <stdio.h>#include <string.h> struct example { int num; char name[16]; }; int main() { example test; example read; FILE *fp; test.num = 1; strcpy(test.name, "Hello World!"); fp = fopen("file.dat", "w+"); if (!fp) { printf("open file error!"); return -1; } rewind(fp); fwrite(&test, sizeof(example), 1, fp); rewind(fp); fread(&read, sizeof(example), 1, fp); printf("%d, %s/n", read.num, read.name); fclose(fp); return 0;