Link to home
Start Free TrialLog in
Avatar of mark_s
mark_s

asked on

ofstream question

I want to open a file and seek to the end of it, but whenever the file is opened using the following code, it is truncated...

std::ofstream queue;

queue.open("file.000", std::ios_base::out | std::ios_base::ate);

any suggestions?
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nke2000
nke2000

std::ios_base::ate sends you to the end of file, is that what you want?
Try using std::ios_base::trunc instead.
Example:
queue.open("file.000", std::ios_base::out | std::ios_base::trunc);
Oops!!!
Disregard my previous comment.
I belive jkr is right.  app is what you want.