making a new results file

I have written a program that sends the results to the screen but I need it to send the results to another file. I am not sure what I need to include in my program to create this new file.

Thanks for your help
im not really good at this stuff, but i guees i can try to help you.

1
2
3
4
5
6
7
8
#include <fstream> //this is what you need to include.


//then where you want it to be printed to a file write:
fstream myfile;
myfile.open("theNameOfYourFile.txt"); //to open the file
myfile << "what you want to write to the file";
myfile.close(); //to close the file 


i hope that works
forgot to add: u need to use namespace std
Last edited on
Topic archived. No new replies allowed.