How to create a file if not exist and open it in read and write modes in C++? For example, I would like open a fstream on
/tmp/cache to be able to read it and append to it. If the file does not exist yet, create one.
A simple code like
std::fstream fs("/tmp/cache", std::ios::in | std::ios::out | std::ios::app);
will not create the file if it does not exist.