#include <errno.h> #include <stdio.h> #include <errno.h> #include <stdlib.h> int main() { char *buf = (char *)malloc(1024*1024); int len, w_len, file_len; FILE *fp = NULL; fp = fopen("hui.txt","wr+"); if(NULL == fp) { fprintf(stdout, "fopen fail:%s\n", strerror(errno)); } w_len = 1024*512; while(1) { len = fwrite(buf, 1, w_len, fp); if(len != w_len) { fprintf(stdout,"fwrite fail:%s\n", strerror(errno)); } len = ftell(fp); fseek(fp, len, SEEK_SET); fprintf(stdout,"TTT------fseek[%s]\n", strerror(errno)); usleep(1000*100); file_len += len; if(1024*1024*400 < file_len) { fprintf(stdout,"fseek----s\n"); file_len = 0; fseek(fp, 0, SEEK_SET); } } return 0; } |
|