I do not understand why sometimes I need to use fflush (), and sometimes not.
Sometimes stdio buffers are sometimes flushed, but it is not. For example, just including "\ n" in printed materials, as a rule, it will hide it (since stdout is attached to the string by default when connected to the terminal).
When the program segfaults, stdout does not clear the buffer automatically?
Stdio buffers are flushed to exit . When a signal (e.g. SIGSEGV ) kills a process, exit not called . Another way to exit the process without flushing stdio buffers is to use the special _exit call for Unix.
source share