### 5.38 `getline`—read a line from a file ¶

Synopsis

    #include <stdio.h>
    ssize_t getline(char **bufptr, size_t *n, FILE *fp);

Description
`getline` reads a file fp up to and possibly including the newline character. The line is read into a buffer pointed to by bufptr and designated with size *n. If the buffer is not large enough, it will be dynamically grown by `getdelim`. As the buffer is grown, the pointer to the size n will be updated.

`getline` is equivalent to getdelim(bufptr, n, ’\n’, fp);

Returns
`getline` returns `-1` if no characters were successfully read, otherwise, it returns the number of bytes successfully read. at end of file, the result is nonzero.

Portability
`getline` is a glibc extension.

No supporting OS subroutines are directly required.