title: Is there a limit to how many times the scanf function can be used?
body: <p>In an effort to get back into the flow of C programming, I've been typing up some simple test programs. I've ran into a strange problem with the scanf function. I have 3 in the following code, but only the first 2 are initialized; the third scanf is ignored. Is this normal, or am I doing something wrong? I've been staring at this code for the last half an hour and I can't find any errors.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int math(int a, int b, char selection) {
  
      int result;
  
      switch (selection) {
          case 'a':
          result = a + b;
          break;
          case 's':
          result = a - b;
          break;
          case 'm':
          result = a * b;
          break;
          case 'd':
          result = a / b;
          break;
      }
  
      return result;
  }
  
  int main() {
      int num1 = 0;
      int num2 = 0;
      int result = 0;
      char selection;
  
      printf("Enter first number: ");
      scanf("%i", &amp;num1);
  
      printf("Enter second number: ");
      scanf("%i", &amp;num2);
  
      printf("\n[a] Add\n[s] Subtract\n[m] Multiply\n[d] Divide\n\nWhich one: ");
      scanf("%c", &amp;selection);
  
      result = math(num1, num2, selection);
      printf("%i", result);
  
      return 0;
  }
  </code></pre>