Difference Between ios::ate and ios::app

EMBED

Thu Apr 08 2021 21:39:39 GMT+0000 (Coordinated Universal Time)

Saved by @wowza12341 #c++


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 is that ios::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 by the other program since your program opened it. ios:app will instead jump to the end of file each time your program adds a log entry.

https://stackoverflow.com/questions/10359702/c-filehandling-difference-between-iosapp-and-iosate#:~:text=ios%3A%3Aapp%20%22set%20the,file%20when%20you%20open%20it.&text=The%20ios%3A%3Aate%20option,to%20the%20end%20of%20file.