title: How to get string input n times?
body: <p>I have a C++ program. I want to get a number from the user (<code>t</code>) and force the user to enter line <code>t</code> times but the program's execution terminates after 1 iteration. This is the code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  int main()
  {
      string str;
      int t;
      cin &gt;&gt; t;
      for (int i=0; i&lt; t; i++) {
          getline(cin, str);
          cout &lt;&lt; str;
      }
      return 0;
  }
  </code></pre>
  
  <p>Can anyone explain me why this happening and how to solve it? 
  Thank you my friends.</p>