超过1G则回头写
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <time.h>
struct timespec interval = {0,10};
char *a = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
char *c = "qwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiop";
int main(int argc,char** agrv)
{
long offset = 0;
constexpr long oneGB = 1024*1024*1024;
FILE* f = fopen("./loopwrite_test","wb+");
while(1){
offset = ftell(f);
if(offset>=oneGB){
rewind(f);
a = c;
}
fwrite(a,100,1,f);
fflush(f);
//nanosleep(&interval,NULL);
}
}