title: scanf keeps \n character in the buffer
body: <p>I'm new to C and i am trying to read 6 <code>integers</code> with <code>scanf</code> .However, i noticed and read that <code>scanf</code> leaves the <code>\n</code> char (which i have in my format string) in the buffer thus "reading" an extra input from the user.On various stack posts i read that this can be simply solved by adding a white space in front of the %d format (e.g: <code>scanf(" %d\n",&amp;var);</code>but that doesn't work for me.What should i do and why does this happen?</p>
  
  <p>Here's my current code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(void) {
      int A[2][3] = {};
      int B[3][2] = {};
      int i,j;
      for(i=0; i &lt; 2;i++) {
          for(j=0; j &lt; 3;j++) {
              scanf(" %d\n", &amp;A[i][j]);
              getchar();
          }
      }
      return 0;
  }
  </code></pre>