title: C: scanf for char not working as expected
body: <p>I was recently running a c program in my PC. It have a for loop in which some char d is scanned. The for loop runs for 3 times. During each running it prints the the count of running and then scans the value of char d. The program is as follows</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  int main(){
      int f;
      char d;
      for(f=0;f&lt;3;f++){
          printf("Choice %d\n", f);
          scanf("%c", &amp;d);
      }
      return 0;
  }
  </code></pre>
  
  <p>Now the trouble is that when I run the program, the for skips the scanf part when f is 1.
  Now if i changed the code as follows </p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  int main(){
      int f;
      int d;
      for(f=0;f&lt;3;f++){
          printf("Choice %d\n", f);
          scanf("%d", &amp;d);
      }
      return 0;
  }
  </code></pre>
  
  <p>Now the program works fine. and scanf is executed for every iteration of for loop.</p>
  
  <p>What does seem to be the problem here? I mean when d is of type int it works fine, but when d is of type char it does not work correctly.</p>