4.3BSD-UWisc/man/cat3/gets.3s




GETS(3S)            UNIX Programmer's Manual             GETS(3S)



NAME
     gets, fgets - get a string from a stream

SYNOPSIS
     #include <stdio.h>

     char *gets(s)
     char *s;

     char *fgets(s, n, stream)
     char *s;
     FILE *stream;

DESCRIPTION
     _G_e_t_s reads a string into _s from the standard input stream
     stdin.  The string is terminated by a newline character,
     which is replaced in _s by a null character.  _G_e_t_s returns
     its argument.

     _F_g_e_t_s reads _n-1 characters, or up through a newline charac-
     ter, whichever comes first, from the _s_t_r_e_a_m into the string
     _s.  The last character read into _s is followed by a null
     character.  _F_g_e_t_s returns its first argument.

SEE ALSO
     puts(3S), getc(3S), scanf(3S), fread(3S), ferror(3S)

DIAGNOSTICS
     _G_e_t_s and _f_g_e_t_s return the constant pointer NULL upon end of
     file or error.

BUGS
     _G_e_t_s deletes a newline, _f_g_e_t_s keeps it, all in the name of
     backward compatibility.





















Printed 12/27/86          May 15, 1985                          1