Standard I/O Extensions
To facilitate the interoperability of the standard i/o library and POSIX i/o, POSIX adds several additional features to the standard i/o library that are exposed through the stdio.h
header.
An open file descriptor number can be associated with a stream, with the FILE *fdopen(int fd, char const *mode);
function. The mode string must correspond to the file access mode used to originally access the file in question.
The reverse operation, int fileno(FILE *stream);
returns the file descriptor number associated with the given stream.
The very useful ssize_t getline(char **lineptr, size_t *n, FILE *stream)
and ssize_t getdelim(char **lineptr, size_t *n, int delimiter, FILE *stream)
functions can be used to read entire lines up to the next delimiter (getline is equivalent to getdelim with delimiter set to a newline character).