GETS(S) XENIX System V GETS(S)
Name
gets, fgets - Gets a string from a stream.
Syntax
#include <stdio.h>
char *gets (s)
char *s;
char *fgets (s, n, stream)
char *s;
int n;
FILE *stream;
Description
gets reads a string into s from the standard input stream
stdin. The function replaces the newline character at the
end of the string with a null character before copying to s.
gets returns a pointer to s.
fgets reads characters from the stream until a newline
character is encountered or until n-1 characters have been
read. The characters are then copied to the string s. A
null character is automatically appended to the end of the
string before copying. fgets returns a pointer to s.
See Also
ferror(S), fopen(S), fread(S), getc(S), puts(S), scanf(S)
Diagnostics
gets and fgets return the constant pointer NULL upon end-
of-file or error.
Notes
gets deletes the newline ending its input, but fgets keeps
it.
Page 1 (printed 8/7/87)