flushall

Syntax

int flushall()

Arguments

none

Return

Returns the number of files flushed.

Description

Writes all remaining data in the writing buffer of all opened files and streams.
The main use of this function is security; ensuring the data is stored in the file in order to protect against crashes. Use this function if your file format allows processing of the partial file.

Example

int FMI_FILE;
if (FMI_FILE = fopen("d:\\FM_image0.fmi", "wb")) {
  // Write out the src pixels as raw data
  for (z = 0; z < Z; ++z) {
    for (y = 0; y < Y; ++y) {
      for (x = 0; x < X; ++x) {
        fputc(src(x, y, z), IMG_FILE);
      }
    }
    flushall(); // ensure complete channel is stored before next channel is written.
  }
}
else
  ErrorOk("Cannot write image file\nDrive is either full or write-protected!");

if (fclose(IMG_FILE))
  ErrorOk("Cannot close image file!");

Also see

fflush

Comments

Everyone can add his comments about his experiences with this function here. Tips for using it are welcome, too.