Q:

Portability issue in file IO

The following code doesn't have any effect when I compile and run it in linux (g++). Is it a portability issue? How can I make it work?
ofstream myfile;
myfile.open("myfile.txt", fstream::in | fstream::out | fstream::app);

A:

A std::ofstream is an output stream. By definition, it cannot input data. So giving it fstream::in as a flag is wrong.
If you want a file stream you can input and output to, use std::fstream.
Admittedly, this may not be what's causing your problem. But it is wrong.

