#include <stdio.h>
#include <string.h>
struct Test
{
int a;
char c;
};
int main()
{
//FILE *fopen(const char *path, const char *mode);
FILE *fp;
struct Test data = {100,'p'};
struct Test data2;
fp = fopen("./file1","w+");
// size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
int n_write = fwrite(&data,sizeof(struct Test),1,fp);
//fwrite(str,sizeof(char)*strlen(str),1,fp);
//int fseek(FILE *stream, long offset, int whence);
fseek(fp,0,SEEK_SET);
//size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
int n_read = fread(&data2,sizeof(struct Test),1,fp);
printf("read %d,%c\n",data2.a,data2.c);
fclose(fp);
return 0;
}
read 100,p