I've been using the read(2) and write(2) functions to read and write to a file given a file descriptor.
Is there any function like this that allows you to put an offset into the file for read/write?
There are pread/pwrite functions that accept file offset:
ssize_t pread(int fd, void *buf, size_t count, off_t offset); ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
Is it possible to get the filename of a file descriptor (Linux) in C?
I want to know the difference between a file descriptor and file pointer. Also, in what scenario would you use one instead of the other?
I'm learning about file descriptors and I wrote this code: #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <fcntl.h> int fdrd, fdwr, fdwt; char c; main (int argc, char *…