By now you should be familiar with using the insertion operator (<<) to write to an output stream such as cout. You use the insertion operator to write to your output file stream the same way.
You should also be familiar with using the extraction operator (>>) to read from an input stream such as cin. You use the extraction operator to read from your input file stream the same way.
You can also read entire lines including whitespace using the getline function, and ignore characters in the stream using the .ignore() function.
Examples:
- ofile << num1 << " " << num2 << endl;
- ifile >> num1 >> num2;
- ifile.ignore();
- ifile.ignore(1000, '\n');
- getline(ifile, name);