Sending data to a .dat file

First of all, I am a beginner, so use the most basic language possible please.

I am using C++, and we have a dataset, and we have to split up the even and odd numbers, which I have already done. Here are the instructions for the part that I do not know how to do:

"Write a function named output. This function will output the odd array to a file named odd.dat and even array to a file named even.dat. This function should be called only if the user wishes to output the data into different file."

Thank you in advance for your help!
What format should the output be in? Human-readable or machine-readable?
Preferably human readable ;)
Simply open the file and output to it like you would to std::cout.
Example:
1
2
3
4
5
6
//Open the file for output as text:
std::ofstream file("output.dat");
file <<"foobar "<<a<<std::endl;
//Optionally close the file. If you don't close it, it will automatically
//be closed when the object is destructed.
file.close();
Last edited on
Topic archived. No new replies allowed.