I know it is bad practice to use globals, so please don't lecture me. However, I am using one global variable and it is doing something wierd. I have a value input from a file to it, and its value works fine throughout that function. As soon as the program leaves that function (and moves to a different cpp file) the value of the variable is lost and becomes 0. I was wondering if anyone knows the cause of this?
The flow is such:
data_driver.cpp calls a function in In_out.cpp
this function has a line that inputs a number from the file and sets a variable to this number
In_out.cpp eventually returns, and in data_driver.cpp the value of that variable is now 0