[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
Re: [LI] C Programming problem
hi,
the problem is because the printf,fprintf,fgets... uses buffered
output. this is basically done to reduce the number of writes.
in case of writing to files the buffer size is equal to block
size, and only when the buffer is full the buffer is writeen to file.
in case of terminals the buffer is line buffered.
the buffer is writeen only when a new line is encountered.
since printf writes to the terminal when the output is not
redirected, putting \n in the printf will cause the output to be writeen
to the terminal immediately.
one more type is unbuffered where there is no buffering.
the default type of buffering can be changed by the setvbuf
function.see the man pages for more details.
this buffering layer which are used by functions in the
stdio library(stdio.h) is writeen by ritchie.
- sharma
--------------------------------------------------------------------
The Linux India Mailing List Archives are now available. Please search
the archive at http://lists.linux-india.org/ before posting your question
to avoid repetition and save bandwidth.