read和write函数
1. read函数
包含头文件
#include
函数原型
ssize_t read(int fd, void *buf, size_t count);...函数功能
read() attempts to read up to count bytes from file descriptor fd into the buffer starting at buf...这是因为,我们用write()函数写入文件之后,这时候读写位置就指在写完后的那个位置,也就是字符串的后面,这样我们在使用read()函数去读的时候就相当于从写入字符串的后面去读的,所以啥也没读到。...= read(fd, buf, sizeof(buf));
if(read_size > 0)
{
write(STDOUT_FILENO, buf, read_size...O_WRONLY);
lseek(fd, 10, SEEK_END);
write(fd, "a", 1);
close(fd);
return 0;
}
我们运行后发现,文件大小从0