Write pointer to file in C

Posted by Sergey on Stack Overflow See other posts from Stack Overflow or by Sergey
Published on 2010-05-04T07:08:01Z Indexed on 2010/05/04 7:18 UTC
Read the original article Hit count: 263

Filed under:
|
|

I have a stucture:

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

I need to write it to binary file.

Student *s = malloc(sizeof(*s));

I fill my structure with data and then i write in to the file:

fwrite(s, sizeof(*s), 1, fp);

In my file doesnt exist a name and surname, it have an adresses of char*. How can i write to file a word, not an adresses?

© Stack Overflow or respective owner

Related posts about c

    Related posts about file