I don't want to change the text inside the file, just the output. The text in the file reads "C++ is difficult and programming is difficult" What I want the program to do is to read that, but replace the word "difficult" with the word "easy", so that it reads as "C++ is easy and programming is easy" actually touching or replacing anything in the text file.
This is what I have so far:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
string line;
ifstream myfile("difficult.txt");
if (myfile.is_open())
{
while (getline(myfile, line))
{
cout << line << '\n';
}
myfile.close();
}
else cout << "Unable to open file";
return 0;
}