top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is Difference between ios::app and ios::out.

+3 votes
3,453 views
What is Difference between ios::app and ios::out.
posted Jan 24, 2014 by Neeraj Pandey

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

0 votes

ios::ate "sets the stream's position indicator to the end of the stream on opening."

ios:app "set the stream's position indicator to the end of the stream before each output operation."

This means the difference that ate puts your position to the end of the file when you open it. ios::app instead puts it at the end of the file every time you flush your stream. If for example you two programs that write to the same log file ios:ate will override anything that was added to the file since your program opend that file. ios:app instead will jump to the end of file each time your programm adds a log entry.

It's well explained Here

answer Feb 25, 2014 by Hiteshwar Thakur
0 votes

The ios::out is the default mode of ofstream. With the mode of the file does not exist, it gets created but if the file exists then its existing contents get deleted.

The ios::app is output mode of ofstream. With the mode of the file does not exist, it gets created but if the file exists then its existing contents are retained and new information is appended to it.

answer Feb 25, 2014 by Sanketi Garg
...