title: Parsing input with scanf in C
body: <p>I've been having a lot of problems trying to figure out how to use <code>scanf()</code>.  It seems to work fine with integers, being fairly straight forward <code>scanf("%d", &amp;i)</code>.</p>
  
  <p>Where I am running into issues is using <code>scanf()</code> in loops trying to read input.  For example:</p>
  
  <pre><code>do {
    printf("counter: %d: ", counter);
    scanf("%c %c%d", &amp;command, &amp;prefix, &amp;input);
  } while (command != 'q');
  </code></pre>
  
  <ol>
  <li><p>When I enter in a validly structured input like <code>c P101</code>, it seems to loop again before prompting me.  This seems to happen even with a single:</p>
  
  <pre><code>scanf("%c", &amp;c) 
  </code></pre>
  
  <p>in a while loop.  It'll do the loop twice before prompting me again.  What is making it loop twice, and how do I stop it?</p></li>
  <li><p>When I enter in less amount of input that programmatically wouldn't have another character or number such as <code>q</code>, pressing enter seems to prompt me to enter more.  How do I get <code>scanf()</code> to process both single and double character entries? </p></li>
  </ol>