I have a code like this:
# in class definition
std::ofstream m_myFile;
## some where in code
m_myFile.open(filename);
and then in several places, I write to the file as follows:
m_myFile << "some data to file"<<std::endl;
This works well, now I need to add a flag to the system, which, if it is not installed, this file should not be created and written. I checked and I can run the application if I do this:
if(createFile)
{
m_myFile.open(filename);
}
and leave the file entry as it is, and I don't get any runtime error in the windows. My question is that if I do not open the file and write to its stream, what is the standard behavior?
Should I get a runtime error or should the thread just forget about the data and not trigger a temporary error?
I am using Visual Studio 2013.
source
share