#include <stdio.h>
int fflush (
FILE* stream); /* stream to flush */
Description
The function fflush enforces a write operation to a data
stream. Associated buffers are emptied and the content is written to
the file. The function writes the File Allocation Record to the file
system along with the file data. fflush leaves the file open.
The parameter stream is a pointer defining the
data stream.
The function is included in the library RL-FlashFS. The prototype
is defined in stdio.h.
Note
On FAT drives, fflush will only flush buffer in the ARM
Run-Time Library and flushed content will remain in the FlashFS
cache buffers. To write entire file content on FAT drive and
create a consistent file with proper size, you must close
the file using the fclose library function.
#include <rtl.h>
#include <stdio.h>
void main (void) {
FILE *fout;
int i;
fout = fopen ("Flush.test", "w");
if (fout != NULL) {
for (i = 'A'; i < 'Z'; i++) {
fputc (i, fout);
}
// Now flush the file buffers
if (fflush (fout)) {
printf ("An error occurred while flushing the buffer.\n");
}
else {
printf ("Writing to the file went OK.\n");
}
fclose (fout);
}
}
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers of your data.