Write pointer to file in C

后端 未结 7 1579
不思量自难忘°
不思量自难忘° 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 10:11

    You will have to do some extra work to write out the data pointed to by the structure elements - probably just write it out element by element.

    Alternatively change your structure to something like this:

    typedef struct
    {
        char name[MAX_NAME_LEN];
        char surname[MAX_SURNAME_LEN];
        int age;
    } Student;
    

提交回复
热议问题