title: scanf() function with different format specifier
body: <p>Below is a program which accepts two character and prints them</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  int main()
  {
      char c1, c2;
      printf("\n Enter characters one : ");
      scanf(" %c", &amp;c1);
      printf("\n Enter character two : ");
      scanf("%c", &amp;c2);
      printf("\n The the characters are %c and %c ", c1, c2);
      return 0;
  }
  </code></pre>
  
  <p>Now one output instance is :-</p>
  
  <pre><code>Enter two characters : a
  The the characters are a and
  </code></pre>
  
  <p>The problem is that I haven't given any space between two format specifier <code>%c</code>
  Here I pressed 'a' and then '\n' which gets stored into c1 and c2 respectively. And thus I got output which was not accepted.</p>
  
  <p>I know how to correct this problem.</p>
  
  <p>Now I make the same program for the integers :-</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  int main()
  {
      int a, b;
      printf("\n Enter two numbers : ");
      scanf("%d%d", &amp;a, &amp;b);
      printf("\n The two numbers are %d and %d ", a, b);
      return 0;
  }
  </code></pre>
  
  <p>Here we will not found any problem.</p>
  
  <p>I think this time we didn't encounter problem because the second input we give is <code>'\n'</code> or space which is not any integer and thus we get a failure in the reading from the <code>scanf()</code> function so the input buffer is still active and if we press the next input as integer then it gets stored into variable <code>'b'</code>.</p>
  
  <p>Can you tell me the reason which I thought is correct or not?</p>
  
  <p>Now if it is correct then what will happen if I press again a character. Then also it should not get stored into the variable <code>'b'</code> but this time 0 gets stored into variable <code>'b'</code>.</p>
  
  <p>So my question is that what is the reason for proper behavior of the program when I'm trying to make the same program with <code>%d</code></p>