title: why does getchar in while not execute after first iteration?
body: <p>I wrote a program to read from input character by character and print it to output and here is my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  main()
  {
  
      int c;
      while((c = getchar()) != EOF)
      {
          printf("%s\n", "log1");
          printf("%c\n", c);
          printf("%s\n", "log2");
      }
  
  }
  </code></pre>
  
  <p>and this is the result:</p>
  
  <pre><code>a(my input)
  log1
  a
  log2
  log1
  
  
  log2
  </code></pre>
  
  <p>but it should have this result:</p>
  
  <pre><code>a
  log1
  a
  log2
  </code></pre>
  
  <p>what's wrong with this program?</p>