save data as text file

it is possible to save the output result in c++ as a text file and use this text file to plot it in python for example.And also how we can save output data into text file?I knew how to open file
like this :
1
2
3
4
ofstream myfile;
myfile.open("result1.txt", ios::out | ios::binary | ios::trunc);
 
myfile.close();


but sofar I do not know how to save data to text file.

Thanks in advance.
Last edited on
Use the operator>> and operator<< like so:

myfile << "Text " << 123 << " Another Text" << endl;

With streams you can easily write all kinds of data as text.
I solved this now.
Thanks
Last edited on
Topic archived. No new replies allowed.