1

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?

Community
  • 1
  • 1
akira hinoshiro
  • 393
  • 2
  • 15
  • First, please only ask one question per question. Second, you last question is generally off topic as coding styles are mainly Primarily opinion based. – NathanOliver Jul 12 '16 at 16:48
  • 1
    [This](http://en.cppreference.com/w/cpp/io/basic_ofstream) should explain the differences well. Also: Is your ENTER key broken? Please cleanup that unreadable wall of text. – πάντα ῥεῖ Jul 12 '16 at 16:49

0 Answers0