Hi guys,
Does anybody know how to write all output to a file please? But trick is I am using Micosoft Visual C++ 2010 Express. There must be an options somewhere? I've not used it very long and don't know how to do this.
Thank you
Hi guys,
Does anybody know how to write all output to a file please? But trick is I am using Micosoft Visual C++ 2010 Express. There must be an options somewhere? I've not used it very long and don't know how to do this.
Thank you
I meant instead of all cout going to a console for them to go to a file, so that I can keep it and read again if necessary.
Thank you,
OK, I didn't know it was bad practice to do that, will keep it in mind.
Currently I am using an ofstream for 1 of the outputs:
But I also need to output a few other things to a file.Code:ofstream outputFile; outputFile.open ("MSE.xls"); // code outputFile << MSE << endl; outputFile.close();
So can I output several things to different files like this:
Is that correct?Code:ofstream outputFile; ofstream fileTwo; outputFile.open ("MSE.xls"); fileTwo.open("weights.xls"); // code outputFile << MSE << endl; fileTwo << weight[i] << endl; outputFile.close(); fileTwo.close(); // etc like this for several files to which I'd like to write
Thank you Elysia,
Yes, but you should also be able to shorten the code into this:
Note that there is no need to close. The files will automatically close once they go out of scope. This is an important technique called RAII.Code:ofstream outputFile("MSE.xls"); ofstream fileTwo("weights.xls"); // code outputFile << MSE << endl; fileTwo << weight[i] << endl; // etc like this for several files to which I'd like to write
OK thank you! Will greatly help.
Kind Regards,