1GETS(3S) GETS(3S)
2
3
4
6 gets, fgets - get a string from a stream
7
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
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 to a newline character, whichever
24 comes first, from the stream into the string s. The last character
25 read into s is followed by a null character. Fgets returns its first
26 argument.
27
29 puts(3), getc(3), scanf(3), fread(3), ferror(3)
30
32 Gets and fgets return the constant pointer NULL upon end of file or
33 error.
34
36 Gets deletes a newline, fgets keeps it, all in the name of backward
37 compatibility.
38
39
40
41 GETS(3S)