I don't get ios::ate

Hi, I am trying to create a program that writes to a text file, but it always deletes all the text already in it. I use ios::ate but it doens't work or I get a compiling error that I don't understand.

myfile.open ("myfile.txt", ios::ate);

This write over all the stuff in the text file. Why?
hi ! why are you using ios::ate?
and you should save you file anytim u add or modif somthing i the file.u shoud be very carefull about the name of ur file writ it in the same way u save it .
did u include the header file fstream?
i mean
#include<fstream>

ifstream inFile;
ofstream outFile;

then
inFile.open("myfile.txt");
outFile.open(" give it any name);

and dont forget to close them both at the end of ur program
:)

Oh ok, thanks, I really appreciate it. I was using ios::ate because isn't it supposed to put the position at the end of the file.
I guess what you are looking for is ios::app, which opens the file to "append" content to it.
ios::ate looks more like for input files.
check out the reference for ofstream::open
i have the same problem but i have to use ios::ate because i want to add info in the file not in the end but at exact location but when i use ios::ate the program deletes everything in the file and then write in the begining waht i want
when i use ios::app i cant move the marker with f.seekp() because it writes the information always in the end
can you explain me what i have to do so that ios::ate to delete nothing
my problem is about writing structures in files by random access
10x
Topic archived. No new replies allowed.