cacodemon1812
New member
- Xu
- 0
Hàm fflush
Khai báo :
Hàm dùng làm sạch vùng đệm của tệp . Nếu thành công hàm cho giá trị 0 , trái lại hàm trả về EOF
Code:
Nguồn: Sưu tầm
Khai báo :
Mã:
int fflush(FILE *stream);
Code:
Mã:
#include <string.h>
#include <stdio.h>
#include <conio.h>
#include <io.h>
void flush(FILE *stream);
int main(void)
{
FILE *stream;
char msg[] = "This is a test";
/* tao 1 tep */
stream = fopen("DUMMY.FIL", "w");
/*ghi mot vai du lieu len tep */
fwrite(msg, strlen(msg), 1, stream);
clrscr();
printf("Press any key to flush DUMMY.FIL:");
getch();
flush(stream);
printf("\nFile was flushed, Press any key to quit:");
getch();
return 0;
}
void flush(FILE *stream)
{
int duphandle;
/* lam sach vung dem */
fflush(stream);
duphandle = dup(fileno(stream));
close(duphandle);
}
Nguồn: Sưu tầm