title: c++ getline loop str
body: <p>I have this c++ code. I want to read two text files called <code>hasil_eta.txt</code> and <code>hasil_T.txt</code>, then store them into one file, called <code>eta_T.txt</code>.</p>
  
  <p>In the file that I was read is a multiple line in 1 column. I want to join two text files and store them in one file.</p>
  
  <p>here is the code </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;sstream&gt;
  #include &lt;iomanip&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  #include &lt;sstream&gt;
  #include &lt;cstdlib&gt;
  #include "rwparams.h"
  
  using namespace std;
  
  string IntToStr(int n){
    stringstream result;
    result &lt;&lt; n;
    return result.str();
  }
  
  int main(){
      ifstream f5;//read eta 
      ifstream f6;//read T 
      ofstream f7;//store it into file
      string hasil_eta;//menampilkan hasil untuk eta
      string hasil_T;//menampilkan hasil untuk T`
  
      int pengulangan = 170;
  
      for (int i = 0; i &lt; pengulangan; i++){
          f5.open("hasil_eta.txt");
          getline(f5, hasil_eta);
  
          f6.open("hasil_T.txt");
          getline(f5, hasil_T);
  
          f7.open("eta_T.txt");
          f7 &lt;&lt; hasil_eta.c_str();
          f7 &lt;&lt; " ";
          f7 &lt;&lt; hasil_T.c_str();
          f7 &lt;&lt; endl;
  
          f7.close();
          f6.close();
          f5.close();
      }
  }
  </code></pre>
  
  <p>My question is how to make a loop to read a file.</p>