1FGETLN(3)                BSD Library Functions Manual                FGETLN(3)
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
12     char *
13     fgetln(FILE *stream, size_t *len);
14

DESCRIPTION

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

RETURN VALUES

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

ERRORS

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

SEE ALSO

47     ferror(3), fgets(3), fgetwln(3), fopen(3), putc(3)
48

HISTORY

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