//* Demonstrating need for fflush *

// This example works well except on Windows7 that knows better and ignores program requests to flush buffers #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> const char fname[] = "fflush.txt"; int main() { FILE *f; printf("Each time inspect the sie of file fflush.txt and then press ENTER\n"); f = fopen(fname, "w"); printf("File opened - check and ENTER:"); getchar(); fprintf(f, "not empty"); printf("File written to - check and ENTER:"); getchar(); fflush(f); printf("File flushed - check and ENTER:"); getchar(); fclose(f); printf("File closed - check and ENTER:"); getchar(); remove(fname); printf("File erased - check and ENTER:"); getchar(); return(0); }