title: fputc vs putc in C
body: <p>I was reading the C programming book by Kernighan and and came across <code>putc</code> and <code>fputc</code>. I didn't quite understand the difference between the two or when would one be used over the other. I found some posts on StackOverflow which dealt with this topic but it's still unclear.</p>
  <p>As mentioned here (<a href="https://stackoverflow.com/questions/4563825/putc-needs-stdout-vs-puts">putc needs stdout, vs puts</a>) :</p>
  <blockquote>
  <ol>
  <li><p>According to Kernighan's book <code>putc</code> is equivalent to <code>fputc</code> but <code>putc</code> could be implemented as a macro and <code>putc</code> may evaluate its stream argument more than once.</p>
  </li>
  <li><p>The difference between <code>putc</code> and <code>fputc</code> is that by using <code>putc</code>, you risk running the macro version which is inherently unsafe because it may have to evaluate its stream argument more than once. This causes complications that most people aren't aware of and thus do not watch out for, so <code>fputc</code> is better to use. <code>fputc</code>'s macro does not have this problem.</p>
  </li>
  </ol>
  </blockquote>
  <p><strong>Questions:</strong></p>
  <ol>
  <li><p><code>putc</code> can be implemented as a macro but what is the problem doing same with <code>fputc</code>?</p>
  </li>
  <li><p>The second statement mentions of some complications and safety issues. What are those?</p>
  </li>
  <li><p><code>putc</code> evaluates its argument more than once. So what are the advantages or disadvantages it poses compared to evaluating the argument.</p>
  </li>
  </ol>