title: Input in a function mixed with input in main
body: <p>Lets say I have a void function and main func of course. </p>
  
  <pre><code>void function() {
      char a, b;
      printf("Enter two chars: ");
      scanf("%c %c", &amp;a, &amp;b);
      // there will be a code that does something with entered chars ...
  }
  
  int main() {
      char c;
      while(1) {
          switch(c = getchar()) {
          case 'v':
              function();
              break;
          case 'c':
              someOtherFunc();
              break;
          }
      }
  }
  </code></pre>
  
  <p>Now, the problem is, when I run the program, I press <code>v</code>, it calls the <code>function()</code> which wants from me 2 characters to input. Okay, I put <code>x</code> and <code>c</code> and what it does is that it calls another function from the switch which is not correct because I do not want to run another function yet.I need to do something with those 2 chars in first function. It is mixing inputs. How can I solve this? I need to have switch available only if function is 100% done with its job. I have several functions in my program and all of them are void. Suggestions?</p>