.\" Copyright (c) 1990 The Regents of the University of California. .\" All rights reserved. .\" .\" %sccs.include.redist.man% .\" .\" @(#)fgetln.3 5.1 (Berkeley) 03/05/91 .\" .TH FGETLINE 3 "" .UC 7 .SH NAME fgetline \- get a line from a stream .SH SYNOPSIS .nf .ft B #include char * fgetline(FILE *stream, size_t *len); .ft R .fi .SH DESCRIPTION .I Fgetline returns a pointer to the next line from the stream pointed to by .IR stream . The newline character at the end of the line is replaced by a '\e0' character. .PP If .I len is non-NULL, the length of the line, not counting the terminating NUL, is stored in the memory location it references. .SH "SEE ALSO" ferror(3), fgets(3), fopen(3), putc(3) .SH "RETURN VALUE" Upon successful completion a pointer is returned; this pointer becomes invalid after the next I/O operation on .I stream (whether successful or not) or as soon as the stream is closed. Otherwise, NULL is returned. .I Fgetline does not distinguish between end-of-file and error, and callers must use .I feof and .I ferror to determine which occurred. If an error occurrs, the global variable .I errno is set to indicate the error. The end-of-file condition is remembered, even on a terminal, and all subsequent attempts to read will return NULL until the condition is cleared with .IR clearerr . .PP It is not possible to tell whether the final line of an input file was terminated with a newline. .PP The text to which the returned pointer points may be modified, provided that no changes are made beyond the terminating NUL. These changes are lost as soon as the pointer becomes invalid. .SH ERRORS .TP 15 [EBADF] .I Stream is not a stream open for reading. .PP .I Fgetline may also fail and set .I errno for any of the errors specified for the routines .IR fflush (3), .IR malloc (3), .IR read (2), .IR stat (2), or .IR realloc (3).