Guest User

Untitled

a guest
Apr 23rd, 2015
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main() {
  7. string data, textOut;
  8.  
  9.  
  10. ifstream dataIn;
  11. dataIn.open("indata.txt");
  12.  
  13. if (dataIn.is_open())
  14. {
  15. while (dataIn.good())
  16. {
  17. getline(dataIn, data);
  18. cout << data << endl;
  19. }
  20. textOut = data;
  21. while (dataIn.is_open())
  22. {
  23. textOut.replace(textOut.find("first"), 6, "second");
  24. textOut.replace(textOut.find("all"), 4, "some");
  25. textOut.replace((textOut.find_last_of("last", 0)), 5, "penultimate");
  26. }
  27.  
  28. dataIn.close();
  29. }
  30. else cout << "Unable to open file. Please confirm you have exact file name and location." << endl;
  31.  
  32.  
  33. ofstream fileOutput;
  34. fileOutput.open("dataout.txt");
  35. fileOutput << textOut;
  36. fileOutput.close();
  37.  
  38. system("pause");
  39.  
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment