if i open a file ouput using ofstream it's openmode is set to ios::out and ios::trunc...

what I have to do, if I want to have only the ios::out flag...not the ios::trunc flag.Because, it is deleting all the previous contents.

How do i undo this flag?or, what to do, if I want to remove it, at the moment of initialization?

Recommended Answers

All 5 Replies

Specify std::ios::ate as the file mode in the constructor.

Or if the file is already open, close it and reopen with std::ios::ate as the file mode.

Also try ios::app.

Thanks.But I wanted to remove the flag because, i want to take the pointers at the start of the file by reopening it.None of the above solutions do it.

seekp & seekg should get the job dont.But they are not working. :(

I assume this belongs to you.

I assume this belongs to you.

yes.

I have tried with clear and ios::beg combination...results are pretty weird...

so, i have decided to try another way around...i will post update today.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.