title: Difference between scanf("%c", &c) and scanf(" %c", &c)
body: <p>Consider the following C code snippet:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main()
  {
      int a;
      char c;
      scanf("%d",&amp;a);
      scanf("%c",&amp;c);
      printf("int=%d\n",a);
      printf("char=%c\n",c);
  }
  </code></pre>
  
  <p>I'm able to input only the integer and not the character.The output is simply the integer value and no value is output for the second printf statement.</p>
  
  <p>However if I use a space before the format specifier:</p>
  
  <pre><code>scanf(" %c",&amp;c);
  </code></pre>
  
  <p>It works as expected. Why is this the case?</p>
  
  <p>Someone told me it has something to do with clearing the input buffer. Could someone shed some light on the same?</p>