#include <stdio.h>
int fflush(FILE *stream);
DESCRIPTION
The function fflush() forces a write of all user-space buffered data
for the given output or update stream via the stream’s underlying write
function. The open status of the stream is unaffected.
#include <stdio.h>
#include <ncurses.h>
#include <string.h>
int main(void)
{
FILE *stream;
char msg[] = "This is a test";
stream = fopen("test2.txt", "w+");
fwrite(msg, strlen(msg), 1, stream);
return 0;
}
#include <stdio.h>
#include <ncurses.h>
#include <string.h>
int main(void)
{
FILE *stream;
char msg[] = "This is a test";
initscr();
stream = fopen("test.txt", "w+");
fwrite(msg, strlen(msg), 1, stream);
printw("%s\\n","press any key to flush the content to file");
getch();
fflush(stream);
printw("%s\\n","press any key to quit");
getch();
endwin();
return 0;
}
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |