fwrite写固定大小长度,超过之后返回文件开头重新写;怎么实现啊,
log_fd = fopen("xxxx.log", "ab+");
if (log_fd != NULL)
{
rval = stat("dsp.log", &statbuf);
if (rval == -1) {
perror("stat failed");
}
else
{
printf("file size = %lld\n", (long long)statbuf.st_size);
}
if((long long)statbuf.st_size > 1024)
{
}
fseek(log_fd, 0, SEEK_END);
len = ftell(log_fd);
if(len > 1024*10)
{
printf("file is big 1024*10\n");
rewind(log_fd);
}
printf("file len: %d cur %d \n", len, cur);
fwrite(sz_degmsg, msglen,1, log_fd);
fclose(log_fd);
加入现在文件大小超过1M,我让他从头循环覆盖写,这样怎么实现不了那?