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?

2
  • First, please only ask one question per question. Second, you last question is generally off topic as coding styles are mainly Primarily opinion based. Commented Jul 12, 2016 at 16:48
  • 1
    This should explain the differences well. Also: Is your ENTER key broken? Please cleanup that unreadable wall of text. Commented Jul 12, 2016 at 16:49

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.