#include <stdio.h>
int main()
{
FILE *fp = NULL;
int i = 0;
fp = fopen("test.txt", "w+");
fclose(fp);
while(i++<1500)
{
fp = fopen("test.txt", "a"); // "注意W+對 int fd = fileno(fp);的影響"
if (fp == NULL)
return 0;
fprintf(fp, "hello%d\n",i);
fflush(fp);
int fd = fileno(fp); //如果是W+ 這裏文件被清空的影響
write(fd, "world\n", sizeof("world\n"));
fclose(fp); // close(fd);也行
}
}