Possible Duplicate:
C++ Filehandling: Difference between ios:app and ios:ate?
What is the difference between these two file opening modes ?
ios:ate sets the get/put pointer position to the end of the file => reading/writing will begin from end, but how is it different from ios::app, which again opens a file in append mode...but when I have created a ofstream and opened it in ios:app mode, the put stream pointer still points to the beginning, how does the appending work then ?
Also I understand that ifstream, ofstream and fstream are high level classes to manage the underlying stream buffer. So does it mean that even in ios:app mode i can read data from a file ?
app
comes from 'append' - all output will be added (appended) to the end of the file. In other words you cannot write anywhere else in the file but at the end.
ate
comes from 'at end' - it sets the stream position at the end of the file when you open it, but you are free to move it around (seek) and write wherever it pleases you.