How can I read/write structures from/to data files? It is relatively straightforward to use fread and fwrite.