1.\" Copyright (c) 1990, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" This code is derived from software contributed to Berkeley by 5.\" Chris Torek and the American National Standards Committee X3, 6.\" on Information Processing Systems. 7.\" 8.\" %sccs.include.redist.man% 9.\" 10.\" @(#)fflush.3 8.1 (Berkeley) 06/04/93 11.\" 12.Dd 13.Dt FFLUSH 3 14.Os 15.Sh NAME 16.Nm fflush , 17.Nm fpurge 18.Nd flush a stream 19.Sh SYNOPSIS 20.Fd #include <stdio.h> 21.Ft int 22.Fn fflush "FILE *stream" 23.Ft int 24.Fn fpurge "FILE *stream" 25.Sh DESCRIPTION 26The function 27.Fn fflush 28forces a write of all buffered data for the given output or update 29.Fa stream 30via the stream's underlying write function. 31The open status of the stream is unaffected. 32.Pp 33If the 34.Fa stream 35argument is 36.Dv NULL , 37.Fn fflush 38flushes 39.Em all 40open output streams. 41.Pp 42The function 43.Fn fpurge 44erases any input or output buffered in the given 45.Fa stream . 46For output streams this discards any unwritten output. 47For input streams this discards any input read from the underlying object 48but not yet obtained via 49.Xr getc 3 ; 50this includes any text pushed back via 51.Xr ungetc . 52.Sh RETURN VALUES 53Upon successful completion 0 is returned. 54Otherwise, 55.Dv EOF 56is returned and the global variable 57.Va errno 58is set to indicate the error. 59.Sh ERRORS 60.Bl -tag -width [EBADF] 61.It Bq Er EBADF 62.Fa Stream 63is not an open stream, or, in the case of 64.Fn fflush , 65not a stream open for writing. 66.El 67.Pp 68The function 69.Fn fflush 70may also fail and set 71.Va errno 72for any of the errors specified for the routine 73.Xr write 2 . 74.Sh SEE ALSO 75.Xr write 2 , 76.Xr fopen 3 , 77.Xr fclose 3 , 78.Xr setbuf 3 79.Sh STANDARDS 80The 81.Fn fflush 82function 83conforms to 84.St -ansiC . 85