|
|
#include <stdio.h>char *gets (s) char *s;
char *fgets (s, n, stream) char *s; int n; FILE *stream;
The gets function reads characters from the standard input stream, stdin, into the array pointed to by s, until a new-line character is read or an end-of-file condition is encountered. The new-line character is discarded and the string is terminated with a null character. See warning below on the use of gets.
The fgets function reads characters from the stream into the array pointed to by s, until n-1 characters are read, or a new-line character is read and transferred to s, or an end-of-file condition is encountered. The string is then terminated with a null character.
fgets is not, however, a direct substitute for gets. With fgets, as soon as the buffer is filled, the remainder of the line is left for the next fgets, while gets always reads the entire line even when it overflows the buffer.
X/Open Portability Guide, Issue 3, 1989
;
ANSI X3.159-1989 Programming Language -- C
;
Intel386 Binary Compatibility Specification, Edition 2 (iBCSe2)
;
IEEE POSIX Std 1003.1-1990 System Application Program Interface (API) [C Language] (ISO/IEC 9945-1)
;
and
NIST FIPS 151-1
.