ios::??

Dec 13, 2011 at 3:43pm
closed account (9wX36Up4)
hey guys simply my question is what is the different between ios::ate and ios::trunc
both clearing the file??
Last edited on Dec 13, 2011 at 3:43pm
Dec 13, 2011 at 4:36pm
ios::ate means you can append to the file from any position you specify within the file. So if you do not specify the position of the file to be written too, it will act like ios::trunc.

ios::trunc ( truncate ) just means it starts the file fresh as if it was empty. So what most people do is read the file in as a buffer .. change it.. and then write it all back out to the file.

In simpler terms :
trunc > Truncate existing file (default behavior)

ate > Opens the file without truncating, but allows data to be written anywhere in the file.
Last edited on Dec 13, 2011 at 4:38pm
Topic archived. No new replies allowed.