title: C++ Edit Text File?
body: <p>I'm creating this simple program which would save me alot of time, but I'm kinda stuck.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  
  using namespace std;
  
  int main()
  {
      vector&lt;string&gt; tempfile;
      string line;
      ifstream oldfile("old.lua");
      if (oldfile.is_open())
      {
          while (oldfile.good())
          {
              getline(oldfile, line);
              tempfile.push_back(line + "\n");
          }
          oldfile.close();
      }
      else
      {
          cout &lt;&lt; "Error, can't find old.lua, make sure it's in the same directory as this program, and called old.lua" &lt;&lt; endl;
      }
  
      ofstream newfile("new.lua");
      if (newfile.is_open())
      {
          for (int i=0;i&lt;tempfile.size();i++)
          {
              for (int x=0;x&lt;tempfile[i].length();x++)
              {
                  newfile &lt;&lt; tempfile[i][x];
              }
          }
          newfile.close();
      }
      return 0;
  }
  </code></pre>
  
  <p>So, what this does now, is just copies a file. But I've tried to do it, so it changes fe. every "function" word to "def", I've tried everything and googled already, couldn't find anything useful enough, only thing I found was using sstream, but it didn't work after all, or maybe I'm just not skilled enough to do it, so if anyone could give me any tips or help, cause I really am stuck? :d</p>