title: Reading enter key in a loop in C
body: <p>How can I read the enter key in a loop multiple times?</p>
  
  <p>I've tried the following with no result.</p>
  
  <pre><code>char c;
  for (i=0; i&lt;n; i++){
      c = getchar ();
      fflushstdin ();
      if (c == '\n'){
          //do something
      }
  }
  </code></pre>
  
  <p>And fflushstdin:</p>
  
  <pre><code>void fflushstdin (){
      int c;
      while ((c = fgetc (stdin)) != EOF &amp;&amp; c != '\n');
  }
  </code></pre>
  
  <p>If I read any other character instead of enter key it works perfect, but with enter key In some iterations I have to press the enter 2 times.</p>
  
  <p>Thanks.</p>
  
  <p>EDIT: I'm executing the program through putty on windows and the program is running on a virtualized linux mint on virtual box.</p>