Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)

gets(3) OSS Library Calls Reference Manual
NAME
gets - Gets a string from the standard input stream
LIBRARY
G-series native Guardian processes: $SYSTEM.SYSnn.ZCRTLSRL
G-series native OSS processes: /G/system/sysnn/zcrtlsrl
H-series and J-series native Guardian processes: $SYSTEM.ZDLLnnn.ZCRTLDLL
32-bit H-series and J-series OSS processes: /G/system/zdllnnn/zcrtldll
64-bit H-series and J-series OSS processes: /G/system/zdllnnn/ycrtldll
SYNOPSIS
#include <stdio.h>
char gets(
char string);
PARAMETERS
string Points to a string to receive bytes.
DESCRIPTION
The gets( ) function reads bytes from the standard input stream, stdin, into the array pointed to by
the string parameter. Data is read until a newline character is read or an End-of-File condition is
encountered. If reading is stopped due to a newline character, the newline character is discarded
and the string is terminated with a NULL character.
CAUTIONS
The gets( ) function does not check the input for a maximum size. Consequently, if more bytes
are entered than will fit in the space allocated for the string parameter, gets( ) will write beyond
the end of the allocated space, producing indeterminate results. To avoid this condition, you
should use fgets( ) instead of gets( ).
RETURN VALUES
If the end of the file 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 the following conditions occur, the gets( ) function sets errno to the corresponding
value:
[EAGAIN] The O_NONBLOCK flag is set for the underlying input stream and the process
would be delayed by the read operation.
[EBADF] The file descriptor underlying the input stream is not a valid file 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 process’s controlling terminal and either
the process is ignoring or blocking the SIGTTIN signal or the process group is
orphaned.
3134 Hewlett-Packard Company 527187-017