1fgetln(3bsd)                         LOCAL                        fgetln(3bsd)
2

NAME

4     fgetln — get a line from a stream
5

LIBRARY

7     Utility functions from BSD systems (libbsd, -lbsd)
8

SYNOPSIS

10     #include <stdio.h>
11     (See libbsd(7) for include usage.)
12
13     char *
14     fgetln(FILE *stream, size_t *len);
15

DESCRIPTION

17     The fgetln() function returns a pointer to the next line from the stream
18     referenced by stream.  This line is not a C string as it does not end
19     with a terminating NUL character.  The length of the line, including the
20     final newline, is stored in the memory location to which len points and
21     is guaranteed to be greater than 0 upon successful completion.  (Note,
22     however, that if the line is the last in a file that does not end in a
23     newline, the returned text will not contain a newline.)
24

RETURN VALUES

26     Upon successful completion a pointer is returned; this pointer becomes
27     invalid after the next I/O operation on stream (whether successful or
28     not) or as soon as the stream is closed.  Otherwise, NULL is returned.
29     The fgetln() function does not distinguish between end-of-file and error;
30     the routines feof(3) and ferror(3) must be used to determine which oc‐
31     curred.  If an error occurs, the global variable errno is set to indicate
32     the error.  The end-of-file condition is remembered, even on a terminal,
33     and all subsequent attempts to read will return NULL until the condition
34     is cleared with clearerr(3).
35
36     The text to which the returned pointer points may be modified, provided
37     that no changes are made beyond the returned size.  These changes are
38     lost as soon as the pointer becomes invalid.
39

ERRORS

41     [EBADF]            The argument stream is not a stream open for reading.
42
43     The fgetln() function may also fail and set errno for any of the errors
44     specified for the routines fflush(3), malloc(3), read(2), stat(2), or
45     realloc(3).
46

SEE ALSO

48     ferror(3), fgets(3), fgetwln(3bsd), fopen(3), putc(3)
49

HISTORY

51     The fgetln() function first appeared in 4.4BSD.
52
53BSD                             April 19, 1994                             BSD
Impressum