"serializing" structs in C

From: copx (invalid_at_invalid.com)
Date: 12/30/03


Date: Tue, 30 Dec 2003 11:15:34 +0100

I want to save a struct to disk.... as plain text.
At the moment I do it with a function that just
writes the data using fprintf. I mean like this:
fprintf(fp, "%d %d", my_struct.a, my_struct.b)
This way I have to write another "serializing"
function for every new kind of struct I want
to write, though. Is there a way to write
functions that can write/read any struct
to/from plain text format in a portable way?

copx


Quantcast