I have asked earlier if there was a combination of openmode to avoid modifications of an existing file. Now I would like to know if the contrary is possible :
std::ios::trunc)Is there an std::ios::openmode available to do that with an std::ofstream?
To the best of my knowledge, there is no such an open mode (it does not look like a very common use case). I guess you could first check whether the file exists and, only if it does, open it with trunc open mode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With