Guardian Native C Library Calls Reference Manual (G06.28+, H06.04+)

gets(3) Guardian Native C 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 native Guardian processes: $SYSTEM.ZDLLnnn.ZCRTLDLL
H-series OSS processes: /G/system/zdllnnn/zcrtldll
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 t 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 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 the following conditions occur, the gets() 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.
336 Hewlett-Packard Company 527192-005