title: How to use "gets" function in C++ after previous input?
body: <p>I tried to input data with <code>gets()</code> function, but whenever program execution get to the the lien with the <code>gets</code>, it ignores it. </p>
  
  <p>When I use <code>gets()</code> without previous data input, it runs properly. But when I use it after data input the problem happens.</p>
  
  <p>Here's the code where it is used after previous data input (so in execution I can't input data to string):</p>
  
  <pre><code>int main() {
      char str[255];
      int a = 0;
      cin &gt;&gt; a;
      if(a == 1) {
          gets(str);
          cout &lt;&lt; "\n" &lt;&lt; str &lt;&lt; endl;
      }
  }
  </code></pre>
  
  <p>How could I fix this?</p>
  
  <p><em>NB: the same happens with cin.getline</em></p>