Query: getdelim
OS: mojave
Section: 3
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
GETLINE(3) BSD Library Functions Manual GETLINE(3)NAMEgetdelim, getline -- get a line from a streamLIBRARYStandard C Library (libc, -lc)SYNOPSIS#include <stdio.h> ssize_t getdelim(char ** restrict linep, size_t * restrict linecapp, int delimiter, FILE * restrict stream); ssize_t getline(char ** restrict linep, size_t * restrict linecapp, FILE * restrict stream);DESCRIPTIONThe getdelim() function reads a line from stream, delimited by the character delimiter. The getline() function is equivalent to getdelim() with the newline character as the delimiter. The delimiter character is included as part of the line, unless the end of the file is reached. The caller may provide a pointer to a malloced buffer for the line in *linep, and the capacity of that buffer in *linecapp. These functions expand the buffer as needed, as if via realloc(). If linep points to a NULL pointer, a new buffer will be allocated. In either case, *linep and *linecapp will be updated accordingly.RETURN VALUESThe getdelim() and getline() functions return the number of characters written, excluding the terminating NUL character. The value -1 is returned if an error occurs, or if end-of-file is reached.EXAMPLESThe following code fragment reads lines from a file and writes them to standard output. The fwrite() function is used in case the line con- tains embedded NUL characters. char *line = NULL; size_t linecap = 0; ssize_t linelen; while ((linelen = getline(&line, &linecap, fp)) > 0) fwrite(line, linelen, 1, stdout);ERRORSThese functions may fail if: [EINVAL] Either linep or linecapp is NULL. [EOVERFLOW] No delimiter was found in the first SSIZE_MAX characters. These functions may also fail due to any of the errors specified for fgets() and malloc().SEE ALSOfgetln(3), fgets(3), malloc(3)STANDARDSThe getdelim() and getline() functions conform to IEEE Std 1003.1-2008 (``POSIX.1'').HISTORYThese routines first appeared in FreeBSD 8.0.BUGSThere are no wide character versions of getdelim() or getline().BSDNovember 30, 2010 BSD
Related Man Pages |
---|
getdelim(3) - mojave |
getdelim(3) - redhat |
getline(3) - redhat |
getline(3) - suse |
getline(3) - freebsd |
Similar Topics in the Unix Linux Community |
---|
syntax about getline of awk |
AWK getline quits inexplicably after many lines |
Using getline in awk |
Count delimiter and replace |
Deleting lines on matching certain pattern |