Write pointer to file in C

后端 未结 7 1580
不思量自难忘°
不思量自难忘° 2020-12-19 09:32

I have a structure:

typedef struct student {
  char *name;
  char *surname;
  int age;
} Student;

I need to write the structure into a bina

7条回答
  •  情深已故
    2020-12-19 09:50

    if you want to directly write the structure as it is to a file you would want to define the sizes of name and surname rather than dynamically allocating it.

    typedef structure student { char name[100]; char surname[100]; int age; } 
    

    else you will need to write each info in the structure one by one.

提交回复
热议问题