Use of fflush() function

Explain the use of fflush() function.

In ANSI, fflush() [returns 0 if buffer successfully deleted / returns EOF on an error] causes the system to empty the buffer associated with the specified output stream.

It undoes the effect of any ungetc() function if the stream is open for input. The stream remains open after the call.

If stream is NULL, the system flushes all open streams.

However, the system automatically deletes buffers when the stream is closed or even when a program ends normally without closing the stream.

The fflush() function is used for clearing the buffer before closing the file. It flushes the currently available pending data of files. All the output units will be flushed, in case the parameter is NULL. It is useful when some set of writes has completed before, like responding to a request.
Difference between malloc() and calloc() function
malloc() and calloc() function - Both functions are used to dynamically allocate the memory. The difference is that calloc initializes the allocated memory to 0 or Null while malloc contains garbage values.....
Difference between strcpy() and memcpy() function
strncpy() is similar to memcopy() in which the programmer specifies n bytes that need to be copied.....
Difference between exit() and _exit() function
exit() and _exit() : exit() does cleanup work like closing file descriptor, file stream and so on, while _exit() does not....
Post your comment
Discussion Board
c language.
use of fflush().it is used for clearing buffer before closing the files.it returns 0 if buffer is successfully.sir please provide more information on fflush function.
srikanth. 06-2-2015