title: What are the rules of automatic stdout buffer flushing in C?
body: <p>I'm just curious which conditions should be satisfied to flush stdout buffer automatically.</p>
  
  <p>First of all I was confused that this pseudo code doesn't print output every iteration:</p>
  
  <pre><code>while (1) {
      printf("Any text");
      sleep(1);
  }
  </code></pre>
  
  <p>But if I add newline character it will. </p>
  
  <p>After few experiments i found that on my machine stdout buffer is flushed:</p>
  
  <ol>
  <li>When I put to stdout 1025 characters or more;</li>
  <li>When I read stdin;</li>
  <li>When I put newline character to stdout;</li>
  </ol>
  
  <p>The first condition is totally clear - when the buffer is full it should be flushed. The second one is also reasonable. But why newline character causes flushing? What are the others implicit conditions for this?</p>