title: C: printf() and putchar() questions
body: <p>I was reading K&amp;R book and wanted to test out printf() and putchar() functions in ways that I never tried. I encountered several unexpected events and would like to hear from more experienced programmers why that happens.</p>
  
  <pre><code>char c;
  while((c = getchar()) != EOF) {
  //put char(c);
      printf("%d your character was.\n", c);
  }
  </code></pre>
  
  <ol>
  <li>How would one get EOF (end of file) in the input stream (getchar() or scanf() functions)? Unexpected key that is not recognized by getchar()/scanf() function could produce it?</li>
  <li>In my book, it says that c has to be an integer, because it needs to store EOF and the variable has to be big enough to hold any possible char that EOF can hold. This doesn't make sense for me, because EOF is a constant integer with a value of -1, which even char can store. Can anyone clarify what was meant by this?</li>
  <li>What happens when I send "hello" or 'hello' to putchar() function? It expects to get an integer, but returns weird output, such as <em>EE</em> or <em>oo</em>, if I send the latter string or char sequence.</li>
  <li>Why when I use printf() function that is written above I get two outputs? One is the one I entered and the other one is integer, which in ASCII is end of line. Does it produce the second output, because I press enter, which it assumes to be the second character?</li>
  </ol>
  
  <p>Thanks.</p>