www.delorie.com/djgpp/doc/libc/libc_315.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

fflush

Syntax

 
#include <stdio.h>

int fflush(FILE *file);

Description

If file is not a NULL pointer, this function causes any unwritten buffered data to be written out to the given file. This is useful in cases where the output is line buffered and you want to write a partial line.

If file is a NULL pointer, fflush writes any buffered output to all files opened for output.

Note that fflush has no effect for streams opened for reading only. Also note that the operating system can further buffer/cache writes to disk files; a call to fsync (see section fsync) or sync (see section sync) is typically required to actually deliver data to the file(s).

Return Value

Zero on success, -1 on error. When called with a NULL pointer, -1 will be returned if an error happened while flushing some of the streams (but fflush will still try to flush all the rest before it returns).

Portability

ANSI/ISO C C89; C99
POSIX 1003.2-1992; 1003.1-2001

Example

 
printf("Enter value : ");
fflush(stdout);
scanf(result);


  webmaster     delorie software   privacy  
  Copyright © 2004     Updated Apr 2004