title: Why does printf() not print anything before sleep()?
body: <p>I'm just learning C with Kernighan and Ritchie's book; I'm in the basics of the fourth chapter (&quot;Functions and Program Structure&quot;). The other day I became curious about the <code>sleep()</code> function, so tried to use it like this:</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;unistd.h&gt;
  
  int main(void)
  {
    printf(&quot; I like cows.&quot;);
    sleep(5);
    return 0;
  }
  </code></pre>
  <p>The problem is the output of the program, it looks like it does the <code>sleep()</code> first and then the <code>printf()</code>, in other words, it waits five seconds and then prints the string. So I thought, maybe the program gets to <code>sleep()</code> so fast that it doesn't let <code>printf()</code> have his work done like I want, that is print the string and then sleep.</p>
  <p>How can I show the string and then put the program to sleep?
  The compiler is GCC 3.3.5 (propolice) in OpenBSD 4.3.</p>