1

Fstream does not create file if it is not there unless it is opened in an append mode. Append mode however forbids overwriting the original data, and I want to be able to seekp and seekg anywhere inside.

Unlike question asked here: std::fstream doesn't create file I have a requirements for it not be in either append or truncate mods and still be able to to seekg and seekp anywhere in thise file.

Community
  • 1
  • 1
Draif Kroneg
  • 743
  • 13
  • 34

1 Answers1

3

It's a little more work, but you could attempt to open the fstream, and if it fails open (and close) an output file stream (ofstream) which creates the file, and then try to reopen the fstream.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621