Yes, it's possible. There are two ways you can do it: with binary files, and with text files.

With binary files, you write the actual representation of the variable in bytes to the file. You can then come along and read it at a later date. (This doesn't work very well if the data you wrote contains pointers to other data.) This method has several pros and cons:
  • Pro: the files use very little disk space.
  • Pro: it's very simple to implement.
  • Con: the files will be rather unportable.
  • Con: complex data types (with pointers and references) must be written with care.
  • Con (pro?): difficult to create and edit by hand.


Or you can convert your data into a textual representation, write that to a file, and at a later date read it in again. For example, you could write 123.456 to a file, rather than the individual bytes that 123.456 is stored with on your particular computer. This method also has several pros and cons:
  • Pro: completely portable.
  • Pro (con?): easy to create and modify by hand.
  • Con: slightly larger file sizes (usually unimportant -- 2KB instead of 300 bytes or something).
  • Con: a little more difficult to implement in code.


I usually use text files, just because I like being able to edit them by hand. (This could be a disadvantage in some cases, but only very rarely.) I also love their portability. Who cares if it takes a few more lines of code . . . .

So, which sounds more appealing? I'm sure, if you ask, someone will give you examples of each . . . .