title: Is stdout line buffered, unbuffered or indeterminate by default?
body: <p>Section <code>7.9.13/7</code> of <code>c99</code> states that:</p>
  <blockquote>
  <p>At program start-up, three text streams are predefined and need not be opened explicitly - standard input (for reading conventional input), standard output (for writing conventional output), and standard error (for writing diagnostic output).</p>
  <p>As initially opened, the standard error stream is not fully buffered; the standard input and standard output streams are fully buffered if and only if the stream can be determined not to refer to an interactive device.</p>
  </blockquote>
  <p>So that makes sense. If you're pushing your standard output to a file, you want it fully buffered for efficiency.</p>
  <p>But I can find no mention in the standard as to whether the output is line buffered or unbuffered when you <em>can't</em> determine the device is non-interactive (ie, normal output to a terminal).</p>
  <p>The reason I ask was a comment to my answer <a href="https://stackoverflow.com/questions/3723658/does-anyone-have-an-example-of-a-conditional-statement-in-c/3723670#3723670">here</a> that I should insert an <code>fflush(stdout);</code> between the two statements:</p>
  <pre><code>printf (&quot;Enter number&gt; &quot;);
  // fflush (stdout); needed ?
  if (fgets (buff, sizeof(buff), stdin) == NULL) { ... }
  </code></pre>
  <p>because I wasn't terminating the <code>printf</code> with a newline. Can anyone clear this up?</p>