In the previous article of this series, titled "File Handling and Streams in C++," you saw how to handle files in an easy and convenient way. Getting input data from a file or putting such data into a file should be familiar to you now. In this article, we'll take a look at some more advanced tasks and tricks so you can gain speed and efficiency in your work.
Advanced File Handling with Streams in C++ (Page 1 of 4 )
From time to time, I will not use streams, as I sometimes prefer the console output, although, as you may know already, that also is handled like a file, so every trick that works on the console IO will compile and run just as well on files. For this article, a minimal knowledge of STL containers and iterators and how they work is necessary.
I won't promise that I'm going to present every little trick, but I will try to show and discuss a few interesting ones. The stream part already forms a pretty strong basis for programming for anyone, but as you will see, once we combine it with some algorithms (found inside the <algorithm> header) it will be even simpler to use, and offer more.
First, let me point out that, as with any stream, the manipulators will work also with the files. If you have not heard about them in general, or how you should handle/use them, please search for my articles covering it. I dedicated two separate articles to the topic, and both of them have appeared (if not, then they are queued) here on the Developer Shed Network.