I have Ubuntu 14.04 with g++14 compiler. I need to output some arrays to a text file. It is all for debug but really important. I get empty files with no output.
Do you realize that you're creating a local instance of Commons class called com in this function? What happens when a local variable goes out of scope?
@jib, Commons is a structure. I use other variables located in this Structure in other parts of the program. I can always access those variables and change them.
I don't understand why I cannot use the std:fstream variables in a similar way.
integrateNONrotated is not a part of Commons structure. It is a part of another class: RealWork.
Do you realize that you're creating a local instance of Commons class called com in this function? What happens when a local variable goes out of scope?
It does not make sense to me. Could you be more specific?
@keskiverto, the line 3 is a declaration. printDebugThreeVas22 is a part of the class "Prints."
It is an awfully long and complicated program and I need a lot of intermediate output for controls.
Thank you guys for looking into it. Any more questions?
I want to stress that everything compiles, I get output in the std::output which is the terminal, it is exactly what I need. The output is simply 1 or 0 but I am looking into the blocks: how many units and how many zeroes I get. I can count them only if they are output in an external file, not the terminal. And I need not only the simple count. I need to evaluate the relative positions of the blocks of 0's & 1's.
I don't understand why I cannot use the std:fstream variables in a similar way.
You can, you're just doing it wrong. You seem to be creating a new instance of this class everywhere you want print something. This new instance does not have files attached to any of the variables.
It does not make sense to me. Could you be more specific?
Remember a class or a struct is just a User Defined Type of variable. They act the same way any of the base types would behave. If you create an instance of a variable within a function that variable is destroyed when the function ends, and unless you have provided a constructor the variables are not initialized to any valid values. You are using a local variable, not some more global variable that was defined earlier.
@jib What is the practical solution? I need to define an output file outside of the printDebugThreeVer22 routine and reuse it many times by appending. How can I do it?