0
What is the difference between ios::out or ios::trunc
Hey programmer i really dont understand what is the purpose of ios::trunc and one more thing why i cant use it like fstream ptr; ptr.open("ram.txt",ios::trunc);
5 Respostas
+ 2
ios::out writes over the original content of a file, and if what you put in a file is bigger than its contents, contents will be completely removed....
+ 1
ios::trunc means that if the file is opened for output operations and it already existed, its previous content is deleted and replaced by the new one.
+ 1
But ios::out starts to write from beginning without deleting previous content.
Also ios::app could be used to append to the file
+ 1
Aleksei Radchenkov thankyou now i get it.😊
0
Aleksei Radchenkov thanks bro but the issue is sometimes ios::out also delete previous content and i dont understand why is happening is there any reason behind it