Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstring>
  4. #include <cstdlib>
  5. const int MAX = 100000;
  6. using namespace std;
  7.  
  8. void change (ifstream&, ofstream&, string&);
  9.  
  10. int main()
  11. {
  12.  
  13.     string name;
  14.     cout << "Enter name: ";
  15.     cin >> name;
  16.  
  17.  
  18.     ifstream in("input.cpp");
  19.     ofstream out("output.cpp");
  20.  
  21.     if (in.fail() or out.fail())
  22.     {
  23.         cout << "!!!!!";
  24.         exit (5);
  25.     }
  26.  
  27.     change (in, out, name);
  28.  
  29.     in.close();
  30.     out.close();
  31.     return 0;
  32. }
  33.  
  34. void change (ifstream& in, ofstream& out, string& name)
  35. {
  36.     char temp[MAX];
  37.  
  38.     in.read(temp, MAX);
  39.  
  40.     string s = temp;
  41.  
  42.     s.replace(s.find("#N#"), 3, name);
  43.  
  44.     out << s;
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement