read() vs pread()

read()

  • ssize_t read(int fd, void buf[.count], size_t count);
  • read from a file descriptor: attempts to read up to count bytes from file descriptor fd into the buffer starting at buf. On files that support seeking, the read operation commences at the file offset and the file offset is incremented by the number of bytes read. If the file offset is at or past the end of file, no bytes are read, and read() returns zero 
  • standard C library (libc, -lc)
  • #include <unistd.h>

pread()

  • ssize_t pread(int fd, void buf[.count], size_t count, off_t offset);
  • read from or write to a file descriptor at a given offset
posted @ 2023-07-31 13:54  球球小世界  阅读(17)  评论(0编辑  收藏  举报