#include#include using namespace std; int main () { ofstream myfile; myfile.open ("example.txt"); myfile << "Writing this to a file.\n"; myfile.flush(); myfile.close(); return 0; }
#includeThis code example shows how the CFile Flush function can be used with the standard C library function fwrite to ensure that any pending output is immediately written to a binary file. The package library for the CFile Flush function is iostream or stdio.h.int main () { FILE * pFile; pFile = fopen ("example.bin","wb"); fwrite (buffer , sizeof(char), sizeof(buffer), pFile); fflush (pFile); fclose (pFile); return 0; }