Open System Services Library Calls Reference Manual (G06.28+, H06.05+)

OSS Library Calls (e - f) fgets(3)
NAME
fgets - Gets a string from a stream
LIBRARY
G-series native Guardian processes: $SYSTEM.SYSnn.ZCRTLSRL
G-series native OSS processes: /G/system/sysnn/zcrtlsrl
H-series native Guardian processes: $SYSTEM.ZDLLnnn.ZCRTLDLL
H-series OSS processes: /G/system/zdllnnn/zcrtldll
SYNOPSIS
#include <stdio.h>
char *fgets(
char *string,
int n,
FILE *stream);
PARAMETERS
string Points to a string to receive bytes.
n Species an upper bound on the number of bytes to read.
stream Points to the FILE structure of an open le.
DESCRIPTION
The fgets() function reads bytes from the data pointed to by the stream parameter into the array
pointed to by the string parameter. Data is read until n-1 bytes have been read, until a newline
character is read and transferred to string, or until an EOF (End-of-File) condition is encountered.
The string is then terminated with a NULL character.
RETURN VALUES
If the end of the le is encountered and no characters have been read, no characters are
transferred to string and a null pointer is returned. If a read error occurs, a null pointer is
returned. Otherwise, string is returned.
ERRORS
If any of these conditions occurs, the fgets() function sets errno to the corresponding value:
[EAGAIN] The O_NONBLOCK ag is set for the underlying input stream and the process
would be delayed by the read operation.
[EBADF] The le descriptor underlying the input stream is not a valid le descriptor or is
not open for reading.
[EINTR] The read operation was interrupted by a signal which was caught and no data
was transferred.
[ENXIO] A request was made on a nonexistent device, or the request was outside the
capabilities of the device.
[EIO] The call is attempting to read from the processs controlling terminal and either
the process is ignoring or blocking the SIGTTIN signal or the process group is
orphaned.
[ENOMEM] Insufcient memory is available for the operation.
[EOVERFLOW]
An attempt was made to read at or beyond the maximum le offset. |
527187-007 Hewlett-Packard Company 239