#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
int main(void)
{
FILE* file = NULL;
if ((file = fopen("log", "w+")) == NULL)
{
perror("fopen");
return -1;
}
char *buf = "qwertyuiopasdfg";
int fd = fileno(file);
while (*buf != '\0')
{
write(fd, buf++, 1);
printf("length = %ld\n", ftell(file));
}
return 0;
}
为什么 输出的长度都为1呢,write写入后 文件指针不是向后移了吗??
慕勒3428872
忽然笑
12345678_0001