title: C: Problems with scanf and printf
body: <p>I'm having issues with accepting user input and the printing its ascii value in C. I'm tasked with writing a program that simply takes a single char as input and prints out its ascii value, and only stops when the user inputs 0 (the ascii value of 0 is 48). My problem is that if the the printf seems to function one loop behind scanf.</p>
  
  <pre><code>while(x == 1){
      scanf("%c\n",&amp;thisChar);
      ascii = thisChar;
      if(ascii == 48){
          x = -1;
      }
      printf("Ascii: %d\n", ascii);
  }
  </code></pre>
  
  <p>For example, when I run this from the command line, I get something like this:</p>
  
  <pre><code>f  
  0  
  Ascii: 102  
  f  
  Ascii: 48  
  </code></pre>
  
  <p>and then the program ends. With those same inputs, I want the output to be:</p>
  
  <pre><code>f  
  Ascii: 102  
  0  
  Ascii: 48  
  </code></pre>
  
  <p>and then end there. What is the error in my logic?</p>