Interesting tutorial, however I did notice a few errors here and there.
if you output abc123 to a
text file you will see abc123 but in a binary file you may see only a bunch of black
blocks if you use notepad
I just tested this, and its not true. If you output "abc123" to a binary file, you will see "abc123" when you open that file in notepad (or any text editor). The difference between binary mode and text mode is that text mode replaces '\n' with something appropriate for the operating system you are using. Different OS's store linebreaks differently: IIRC Windows uses "\n\r" pairs, unix uses '\n' and macs use '\r'. Text mode will translate between these automatically for you, binary mode will not.
If a file handle is used
more than once without calling a close() in between them there will be errors
If you open an ofstream object with a file name, and write output to it, then call open() on the same file stream without closing it, there will be no errors. The call to open() will close the file you were writing to and just open another file. Similarly:
If you forget to close it [the fstream object]
next time you run the program it will show access errors to the C: drive (or which ever drive
you use) and you will have to restart the computer.
The destuctor of an fstream object will close any file handles for you. The last program I made left an open file handle at the end of the program. There was no problem with this, as when the destructor of the ofstream object was called, it closed the file handle automatically. Destructors are guaranteed to be called for all objects at the end of their life (for a global object at the end of the program) so there is no problem leaving file handles open. The only possible problem with this is if your program causes a seg fault or something similar, and the OS has to close it unexpectedly. In that case you have more problems than open file handles though. I do so love the fstream library. Its so hard to f*ck thinks up with it.
It was a very interesting tutorial though. You did a lot with fstream that I wouldn't have thought of.