1GETS(3S)                                                              GETS(3S)
2
3
4

NAME

6       gets, fgets - get a string from a stream
7

SYNOPSIS

9       #include <stdio.h>
10
11       char *gets(s)
12       char *s;
13
14       char *fgets(s, n, stream)
15       char *s;
16       FILE *stream;
17

DESCRIPTION

19       Gets  reads  a string into s from the standard input stream stdin.  The
20       string is terminated by a newline character, which is replaced in s  by
21       a null character.  Gets returns its argument.
22
23       Fgets  reads  n-1 characters, or up through a newline character, which‐
24       ever comes first, from the stream into the string s.  The last  charac‐
25       ter  read  into  s  is followed by a null character.  Fgets returns its
26       first argument.
27

SEE ALSO

29       puts(3S), getc(3S), scanf(3S), fread(3S), ferror(3S)
30

DIAGNOSTICS

32       Gets and fgets return the constant pointer NULL upon  end  of  file  or
33       error.
34

BUGS

36       Gets  deletes  a  newline,  fgets keeps it, all in the name of backward
37       compatibility.
38
39
40
417th Edition                      May 15, 1985                         GETS(3S)
Impressum