title: C: fwrite() vs (f)printf?
body: <p>I was reading the manual page for the <code>getline</code> function and saw a demonstration of it :</p>
  <pre><code> #define _GNU_SOURCE
         #include &lt;stdio.h&gt;
         #include &lt;stdlib.h&gt;
  
         int
         main(int argc, char *argv[])
         {
             FILE *stream;
             char *line = NULL;
             size_t len = 0;
             ssize_t nread;
  
          ...
             while ((nread = getline(&amp;line, &amp;len, stream)) != -1) {
                 printf(&quot;Retrieved line of length %zu:\n&quot;, nread);
                 fwrite(line, nread, 1, stdout); /* ? */
             }
  
             free(line);
             fclose(stream);
             exit(EXIT_SUCCESS);
         }
  
  </code></pre>
  <p>I replaced the <code>fwrite()</code> statement with <code>printf (&quot;%s&quot;, line)</code> and it produced
  identical results (compared using <code>cmp</code> and <code>diff</code>). I am aware of the distinction  between <code>fwrite</code> and <code>fprint</code> but was there any specifc reason the author chose to use <code>fwrite()</code> over <code>fprintf</code> or <code>printf</code> in this context ?</p>