Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- int main() {
- string data, textOut;
- ifstream dataIn;
- dataIn.open("indata.txt");
- if (dataIn.is_open())
- {
- while (dataIn.good())
- {
- getline(dataIn, data);
- cout << data << endl;
- }
- textOut = data;
- while (dataIn.is_open())
- {
- textOut.replace(textOut.find("first"), 6, "second");
- textOut.replace(textOut.find("all"), 4, "some");
- textOut.replace((textOut.find_last_of("last", 0)), 5, "penultimate");
- }
- dataIn.close();
- }
- else cout << "Unable to open file. Please confirm you have exact file name and location." << endl;
- ofstream fileOutput;
- fileOutput.open("dataout.txt");
- fileOutput << textOut;
- fileOutput.close();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment