title: Using the scanf function in while loop
body: <p>I am attempting to format a space-delimited user input for a programming assignment.</p>
  
  <p>Essentially, the input consists of an arbitrary number of expressions</p>
  
  <p><code>L integer integer integer integer</code> and <code>C integer integer integer</code>. </p>
  
  <p>For example: <code>L 1 1 5 7 C 4 5 3</code>.</p>
  
  <p>So far, I've managed to extract the integers depending on the initial character, and can iterate through the string using the scanf function:</p>
  
  <pre><code>char a;
  while(scanf("%c", &amp;a) == 1){
      if(a == 'C'){
          int inputX, inputY, inputR;
          scanf("%d %d %d", &amp;inputX, &amp;inputY, &amp;inputR);
          printf("%d %d %d\n", inputX, inputY, inputR);
      }
      else if(a == 'L'){
          int x1, y1, x2, y2;
          scanf("%d %d %d %d", &amp;x1, &amp;y1, &amp;x2, &amp;y2);
          printf("%d %d %d %d\n", x1, y1, x2, y2);
      }
  }
  </code></pre>
  
  <p>Unfortunately, although this outputs the desired integers, the loop (and user input prompt) doesn't terminate.</p>
  
  <p>Could someone please enlighten me as to why this is happening?</p>