Upon successful completion 0 is returned.
is returned and the global variable
is set to indicate the error.
is not an open stream, or is not open for writing.
may also fail and set
for any of the errors specified for the routine
only flushes the user space buffers provided by the C library.
To ensure that the data is physically stored on disk
the kernel buffers must be flushed too, for example, with