The main things you need to learn are opening and closing files, creating file pointers, and operators and functions used to read/write to a file. Here's an example of file in/out:
1 2 3 4 5 6 7 8 9 10 11 12
#include<fstream>
usingnamespace std;
main ()
{
ofstream outfile;// declaration of file pointer named outfile
outfile.open("filename", ios::out); // opens file named "filename" for output
outfile << "Hello";//saves "Hello" to the outfile with the insertion operator
outfile.close();// closes file; always do this when you are done using the file
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13
#include<fstream>// needed for file in/out
#include<iostream>
usingnamespace std;
main ()
{
ifstream infile;// declaration of file pointer named infile
infile.open("filename", ios::in);// opens file named "filename" for input
cout << getline(infile); // I'm not actually sure if this line will work
infile.close();//closes file
return 0;
}
This example is no substitute for a proper tutorial. There are many other things you need to learn.