c - Does reading from stdin flush stdout? -


stdout is a line-buffer when connecting to a terminal, but I remember reading somewhere (at least stdin) automatic Flush standout all the implementations I have used have done this, but I can not get it now in the standard.

It seems that it works like that, otherwise code like this:

  printf ("Type some input:"); Fgets (line, line of shape, stdin);  

will need an additional Fflush (stdout);

Is there a need for a stand out here to be flavored here?

Edit:

As many answers have said, in the standard no embarrassment seems to be in my example The output is read from Stdin before stdout, but on the other hand, this effect is given in the standard (my free draft copy):

Input and output dynamics of interactive devices 7.1 9 Must be as specified. The intent of these requirements is to ensure that the signal that appears when the message appears to be actually appearing before any program that is waiting for input, without clutter or line-buffer output will appear as soon as possible.

(ISO / IEC 9899: TC2 Committee Draft - May 6, 2005, page 14).

It seems that there is no guarantee in it, but it will probably work in most implementations. (Famous last word ...)

To answer your question, you To make sure that your printf () calls requires an additional flags (stdout) before trying to read the input to your program; Call . Reading with stdin flt (stdout); is not for you.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -