I am not aware what exactly is the difference between these two versions. If you want to only write a file in c++ you can do 2 things.
std::fstream(fileNameStr, std::ios::out);
std::ofstream(fileNameStr);
There is a question and answer what it does ofstream what it does and trunc where it is said std::ofstream
is for writing only and there can be a problem not creating a file when not using std::ios::trunc
.
In std::fstream
std::ios::trunc
deletes all contents I know, so this can be wrong from what I want.
I tried it in VC14 and gcc-4.9 (x86) and it creates a file which is not existent.
What I want to know, is there anything said in the c++ standard what happens with non existent files, and can I run into problems with ARM gcc or other compilers?
Can I run into trouble using this on different architectures at all?