title: How to edit the specific line in a text file?
body: <p>How should I edit the specific line in a text file? And how should I avoid overwriting issue. ( How do I keep the record I had added before instead of replacing them by the new records?)</p>
  
  <p>I tried to use line.replace but it says " No matching member function for  call to replace ".                       </p>
  
  <pre><code>else if(choice == 4){
  
  //            count++;
  
      string edit;
      string newdate;
      double newincome;
      double newoutcome;
      double EditTodayBalance = 0;
      string emptySpace = "         ";
  //            string sentence;
  
      cout &lt;&lt; " There are " &lt;&lt; count &lt;&lt; " record(s) in the file " &lt;&lt;     endl;
      cout &lt;&lt; " Please enter the date to edit " &lt;&lt; endl;
      cin &gt;&gt; edit;
  
  
  
      size_t pos;
      ifstream Record("BankRecord.txt");
      if (Record.is_open()) {
          while (getline(Record, line)) {
              pos = line.find(edit);
              if (pos != string::npos) // string::npos is returned if 
  string is not found
                  {
                      cout &lt;&lt; line &lt;&lt; endl;
  
                      cout &lt;&lt; " Enter what you want to replace " &lt;&lt; endl;
  
                      cout &lt;&lt; " Please enter the new date you want to put " &lt;&lt; endl;
                      cin &gt;&gt; newdate;
                      cout &lt;&lt; " Please enter the new income you want to put " &lt;&lt; endl;
                      cin &gt;&gt; newincome;
                      cout &lt;&lt; " Please enter the new outcome you want to put " &lt;&lt; endl;
                      cin &gt;&gt; newoutcome;
  
                      cout &lt;&lt; "            Your new Record is                 " &lt;&lt; endl;
                      cout &lt;&lt; count &lt;&lt; emptySpace &lt;&lt; newdate &lt;&lt; emptySpace &lt;&lt; newincome &lt;&lt; emptySpace &lt;&lt; newoutcome &lt;&lt; endl;
  
  
                      //line.replace()
              }
          }
      }
      EditTodayBalance = newincome - newoutcome;
      cout &lt;&lt; " Today's balance is " &lt;&lt; EditTodayBalance &lt;&lt; endl;
  
      cout &lt;&lt; " Please reenter your choice " &lt;&lt; endl;
      cin &gt;&gt; choice;
  }
  </code></pre>
  
  <p>I expect if the old line is " 1      2/2/2019      32      21 " and I input the new line to be " 1       2/3/2019        22      11 ". Then when I open the file the record will be the new one.</p>