xxxxxxxxxx
ofstream: Stream class to write on files.
ifstream: Stream class to read from files.
fstream: Stream class to both read and write from/to files.
xxxxxxxxxx
#include <fstream> // iostream isn't required for using fstream
using namespace std;
int main() {
fstream file;
file.open("file.txt"); // Replace file.txt with your own filename
// Reading from files
string input; // A variable is needed for reading from files
file >> input; // Reads the text in the file and saves it to input
// Writing to files
file << "Hello World!";// << endl;
file.close();
return 0;
}