Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - fflush() write any data in a file buffer to disk http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 fflush()            Write any data in a file buffer to disk
------------------------------------------------------------------------------
 Declaration
   fileio.hdr

 Syntax
   proc fflush extern
   param file fStream

 Arguments
   fStream is the file stream to manipulate.

 Return
   None.

 Description
   The fflush() procedure writes any data in the file buffer associated with
   fStream to the disk file. fStream must have been opened in any of the
   file write modes.

 Example
   #define EXAMPLE_FILE
   #include example.hdr

   // Write contents of video mmeory to a file
   
   proc Test_fflush
   vardef
      file        fTemp
      ptr( byte ) pMem, pEnd
   enddef
   pMem := vidaddr()                                // get video address
   pEnd := pMem + 32768UI                           // set end pointer
   if fopen( fTemp, "mem.txt", F_CREATE, F_BINARY ) // open file
      do while pMem < pEnd                          // file write loop
         fputc( fTemp, *pMem )                      // write a byte
         if pMem % 0x1000 == 0                      // at certain intervals
            fflush( fTemp )                         // flush file buffer
            ? dechex( pMem )                        // show progress
         endif
         pMem++                                     // increment pointer
      enddo
      fclose( fTemp )                               // close file
      erase "mem.txt"                // comment out to examine the file
   endif
   endproc

   proc main
   Test_fflush()
   endproc

See Also: fclose() fopen()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson