I am writing a programme to open a file, do some reformating of the data and write the result to an output file. Within function main the input file name is deconstructed and used to create the output file name, which is opened as an ofstream. Some header is written to this file, but the bulk of the writing, including a little bit of arithmetical calculation, I want to do in a function which will be periodically called from the main function.
The problem is that I don't know how to pass the name of the output stream to the function. ofstream is declared in main, so its scope is limited to main and it is therefore not available as an object in the output writing function. I have tried adding an extra parameter to the function of type ofstream, but this creates lots of compiler errors in ios_base.h (I am using the Dev C++ compiler).
Grateful for any advice on how to do this.