Interview Questions

My programs prompts and intermediate output dont always show up on the screen ...

C Interview Questions and Answers


(Continued from previous question...)

My programs prompts and intermediate output dont always show up on the screen ...

Q: My program's prompts and intermediate output don't always show up on the screen, especially when I pipe the output through another program.

A:It's best to use an explicit fflush(stdout) whenever output should definitely be visible (and especially if the text does not end with \n). Several mechanisms attempt to perform the fflush for you, at the ``right time,'' but they tend to apply only when stdout is an interactive terminal.

(Continued on next question...)

Other Interview Questions