The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

gets - get a string from a stdin stream

 SYNOPSIS



#include <stdio.h>

char *gets(char *s);

 DESCRIPTION

The gets() function reads bytes from the standard input stream, stdin, into the array pointed to by s, until a newline is read or an end-of-file condition is encountered. Any newline is discarded and a null byte is placed immediately after the last byte read into the array.

The gets() function may mark the st_atime field of the file associated with stream for update. The st_atime field will be marked for update by the first successful execution of fgetc(), fgets(), fread(), getc(), getchar(), gets(), fscanf() or scanf() using stream that returns data not supplied by a prior call to ungetc().

 RETURN VALUE

Upon successful completion, gets() returns s. If the stream is at end-of-file, the end-of-file indicator for the stream is set and gets() returns a null pointer. If a read error occurs, the error indicator for the stream is set, gets() returns a null pointer and sets errno to indicate the error.

 ERRORS

Refer to fgetc().

 EXAMPLES

None.

 APPLICATION USAGE

Reading a line that overflows the array pointed to by s causes undefined results. The use of fgets() is recommended.

 FUTURE DIRECTIONS

None.

 SEE ALSO

feof(), ferror(), fgets(), <stdio.h>.

DERIVATION

Derived from Issue 1 of the SVID.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]