Next: getline, Previous: getchar_unlocked, Up: Stdio

### 4.36 `getdelim`—read a line up to a specified line delimiter

Synopsis

         #include <stdio.h>
         int getdelim(char **bufptr, size_t *n,
             int delim, FILE *fp);

Description
`getdelim` reads a file fp up to and possibly including a specified delimiter delim. 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.

Returns
`getdelim` 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
`getdelim` is a glibc extension.

No supporting OS subroutines are directly required.