1*61180Sbostic.\" Copyright (c) 1990, 1991, 1993 2*61180Sbostic.\" The Regents of the University of California. All rights reserved. 347006Sbostic.\" 447006Sbostic.\" This code is derived from software contributed to Berkeley by 550291Sbostic.\" Chris Torek and the American National Standards Committee X3, 650291Sbostic.\" on Information Processing Systems. 750291Sbostic.\" 847006Sbostic.\" %sccs.include.redist.man% 947006Sbostic.\" 10*61180Sbostic.\" @(#)fflush.3 8.1 (Berkeley) 06/04/93 1147006Sbostic.\" 1248351Scael.Dd 1348351Scael.Dt FFLUSH 3 1448351Scael.Os 1548351Scael.Sh NAME 1648351Scael.Nm fflush , 1748351Scael.Nm fpurge 1848351Scael.Nd flush a stream 1948351Scael.Sh SYNOPSIS 2048351Scael.Fd #include <stdio.h> 2148351Scael.Ft int 2248351Scael.Fn fflush "FILE *stream" 2348351Scael.Ft int 2448351Scael.Fn fpurge "FILE *stream" 2548351Scael.Sh DESCRIPTION 2648351ScaelThe function 2748351Scael.Fn fflush 2848351Scaelforces a write of all buffered data for the given output or update 2948351Scael.Fa stream 3047006Sbosticvia the stream's underlying write function. 3148351ScaelThe open status of the stream is unaffected. 3248351Scael.Pp 3347006SbosticIf the 3448351Scael.Fa stream 3548351Scaelargument is 3648351Scael.Dv NULL , 3748351Scael.Fn fflush 3847006Sbosticflushes 3948351Scael.Em all 4047006Sbosticopen output streams. 4148351Scael.Pp 4248351ScaelThe function 4348351Scael.Fn fpurge 4447006Sbosticerases any input or output buffered in the given 4548351Scael.Fa stream . 4647006SbosticFor output streams this discards any unwritten output. 4747006SbosticFor input streams this discards any input read from the underlying object 4847006Sbosticbut not yet obtained via 4948351Scael.Xr getc 3 ; 5047006Sbosticthis includes any text pushed back via 5148351Scael.Xr ungetc . 5248351Scael.Sh RETURN VALUES 5347006SbosticUpon successful completion 0 is returned. 5447006SbosticOtherwise, 5548351Scael.Dv EOF 5647006Sbosticis returned and the global variable 5748351Scael.Va errno 5847006Sbosticis set to indicate the error. 5948351Scael.Sh ERRORS 6048351Scael.Bl -tag -width [EBADF] 6148351Scael.It Bq Er EBADF 6248351Scael.Fa Stream 6347006Sbosticis not an open stream, or, in the case of 6448351Scael.Fn fflush , 6547006Sbosticnot a stream open for writing. 6648351Scael.El 6748351Scael.Pp 6848351ScaelThe function 6948351Scael.Fn fflush 7047006Sbosticmay also fail and set 7148351Scael.Va errno 7247006Sbosticfor any of the errors specified for the routine 7348351Scael.Xr write 2 . 7448351Scael.Sh SEE ALSO 7548351Scael.Xr write 2 , 7648351Scael.Xr fopen 3 , 7748351Scael.Xr fclose 3 , 7848351Scael.Xr setbuf 3 7948351Scael.Sh STANDARDS 8048351ScaelThe 8148351Scael.Fn fflush 8248351Scaelfunction 8348351Scaelconforms to 8448351Scael.St -ansiC . 85