title: The difference between stdout and STDOUT_FILENO
body: <p>I was wondering the difference between <code>stdout</code> and <code>STDOUT_FILENO</code> in Linux C.</p>
  
  <p>After some searching work, I draw the following conclusion. Could you help me review it and correct any mistake in it? Thanks</p>
  
  <ul>
  <li><p><code>stdout</code> belongs to standard I/O stream of C language; whose type is FILE* and defined in stdio.h</p></li>
  <li><p><code>STDOUT_FILENO</code>, possessing an int type, is defined at <code>unistd.h</code>. It's a file descriptor of LINUX system. In <code>unistd.h</code>, it's explained as below:</p></li>
  </ul>
  
  <blockquote>
  <pre><code>The following symbolic constants shall be defined for file streams:
  
  STDERR_FILENO
      File number of stderr; 2.
  STDIN_FILENO
      File number of stdin; 0.
  STDOUT_FILENO
      File number of stdout; 1.
  </code></pre>
  </blockquote>
  
  <p>So, in my opinion, the <code>STDOUT_FILENO</code> belongs system-level calling and, to some extent, like a system API. <code>STDOUT_FILENO</code> can be used to describe any device in system. </p>
  
  <p>The <code>stdout</code> locates in a higher level (user level?) and actually encapsulate the details of <code>STDOUT_FILENO</code>. <code>stdout</code> has I/O buffer.</p>
  
  <p>That's my understand about their difference. Any comment or correction is appreciated, thanks.</p>