I have problems with the above approach. Aside from the obvious flaw of not playing nice, and suddenly not being able to use all of my handy tools like grep and head and cut and fold on said data, here is why this is bad:

There's a reason why UNIX people tend to put their files in ASCII. And it's not that hard to use fprintf(), fscanf(), dprintf(), ... Everybody else is doing it!

Don't pretend ASCII storage is limited to UNIX, either. Look at all the Windows applications with INI files, or take a look at the data forks of files in an (old) Mac OS box's Preferences folder. Or hey, look at XML.


If you really want to use this approach, though, here's a tip: the mmap() system call.