I’m facing something strange with a C++ code I’m working on. It’s about an “ofstream” object that I created in order to have the data I need in a file.
Anyways, I need to place this object, which I call output1 after an “if” condition. So, any data that passes the condition I want then in the file.
Now, if I put the usual “cout” after the condition:
.
.
if (Check == 0) cout << data1 << " " << data2 << endl;
.
I’ll get results printed on the screen.
But when I put my output1,
if (Check == 0) output1 << data1 << " " << data2 << endl;
then nothing is written in the file!
I have checked that my output1 object works fine somewhere else in the code. But not here! And the complier didn’t mention any error or lack of declaration.
Any ideas?
Note: I can’t put the code here, or even the relevant parts as it is a very long code and is not meant to be public, so I don’t have the right to copy it.
My crystal ball tells me you have two different objects both named
output1.The
ifstatement definitely has no effect on the problem.