title: Inputting characters and integers in a line in c reading characters from past input stream
body: <p>I was always bad at inputting characters in C and this is another example. Though I understood (maybe) what's happening but I can't figure out the solution.</p>
  
  <p>I have the following code</p>
  
  <pre><code>scanf("%ld %ld",&amp;n,&amp;m);
  
  for(i=0;i&lt;n;i++)
      scanf("%ld",&amp;array[i]);
  
  for(i=0;i&lt;m;i++)
  {
      fflush(stdin);
      //inputting a character 'R' but it is picking '\n' from past buffer
      scanf("%c",&amp;query);
  
      //As a result of above problem, it is also acting wierd for same reason
      scanf("%ld",&amp;d);
  
      printf("%c %ld",query,d);
      printf("\nI=%ld\n",i);
  }
  </code></pre>
  
  <p>Please help me figure out the reason why its happening and what is the solution.</p>