|
| fflush| Summary | |
#include <stdio.h>
int fflush (
FILE *stream); /* stream to flush */
| | Description | | The fflush function flushes the specified file stream. If the file associated with stream is open for output, the contents of the buffer associated with the stream are written to the file. The fflush function is in the RL-FlashFS library. The prototype is defined in stdio.h. Note - This function writes the File Allocation Record to the file system along with the file data. Unlike the fclose function, the fflush function leaves the file open for continued writes.
| | Return Value | | The fflush function returns a value of 0 if successful. A return value of EOF indicates an error. | | See Also | | fclose, fopen | | Example | |
#include <rtl.h>
#include <stdio.h>
void main (void) {
FILE *fout;
int i;
fout = fopen ("Flush.test","r");
if (fout == NULL) {
printf ("File open error!\n");
}
else {
for (i = 'A'; i < 'Z'; i++) {
fputc (i, fout);
}
// Now flush the file buffers
fflush (fout);
fputs ("Write to an empty file buffer.", fout);
fclose (fout);
}
}
|
|
|