#include <unistd.h>
ssize_t read(int fd, void *buf, size_t count);
参数:
fd: open 返回的文件描述符
buf: 读取存放数据
count:读取的数据大小
ssize_t write(int fd, const void *buf, size_t count);
参数:
fd: open 返回的文件描述符
buf: 写入数据
count:写入的数据大小
返回值:
On success, the number of bytes read or written is returned
On error, -1 is returned, and errno is set appropriately. In this case, it is left unspecified whether the file
position (if any) changes.
#include <sys/types.h>
#include <unistd.h>
off_t lseek(int fd, off_t offset, int whence);
参数:
fd: open 返回的文件描述符
offset: 偏移大小
whence: 从何处开始偏移
返回值:
Upon successful completion, lseek() returns the resulting offset location as measured in bytes from
the beginning of the file. On error, the value (off_t) -1 is returned and errno is set to indicate the error.