I need to print output into a different file after the program compiles. For example, filename.cpp compiles, and I want the results printed into file.txt . I have looked in my book, made sure I included things like ofstream and such. I also looked around this website, but couldn't find any other posts that answered my question. I am using VC++ 2010 express as the compiler, and Windows 7 notepad as the editor. Let me know if I should post my code, if that will be more helpful. Thanks!
still having trouble with the actual file output. Here is part of the code where I think something may be messed up:
ofstream fout;
fout.open ("farenheit.txt"); // I think the problem is here with the "farenheit.txt"
if (!fin.good()) throw "I/O error";
fout << F << endl;
fout.close ();
The output goes to the compiler, which is what I want. However, I need it to also go to the farenheit.txt
You have no code to print to the console, so it is impossible that you are seeing console output. There is nothing wrong with your code, except that you should be checking if the file is open rather than if it is good.