读书人

求解大牛们一个c语言不间断写入有关问

发布时间: 2013-01-21 10:15:38 作者: rapoo

求解大牛们一个c语言不间断写入问题
我的代码如下:
int main()
{
FILE *fp;
int count = 0;

fp = fopen("./power.txt","wb");
if(fp == NULL)
{
perror("fopen");
exit(1);
}

do
{
count = fwrite("hello",5,1,fp);
printf("count = %d\n",count);

if(count != 1)
{
perror("fwrite");
exit(1);
}
usleep (300000);
}
while (1);
fclose(fp);

return 0;
}

但是power.txt里面并没有hello 如果去掉while语句就有hello各位大牛们 怎么才能不间断向文件写数据呢 c fwrite
[解决办法]
fflush函数就是干这个的。

读书人网 >C语言

热点推荐