one too many levels of indirection (from ks@purdue)
[unix-history] / usr / src / lib / libc / stdio / gets.3
CommitLineData
92e5df88 1.\" @(#)gets.3 6.1 (Berkeley) %G%
2e146d0b 2.\"
92e5df88 3.TH GETS 3S ""
2e146d0b
KM
4.AT 3
5.SH NAME
6gets, fgets \- get a string from a stream
7.SH SYNOPSIS
8.B #include <stdio.h>
9.PP
10.B char *gets(s)
11.br
12.B char *s;
13.PP
14.B char *fgets(s, n, stream)
15.br
16.B char *s;
17.br
18.SM
19.B FILE
20.B *stream;
21.SH DESCRIPTION
22.I Gets
23reads a string into
24.I s
25from the standard input stream
9ecd5650 26.BR stdin .
2e146d0b
KM
27The string is terminated by a newline
28character, which is replaced in
29.I s
30by a null character.
31.I Gets
32returns its argument.
33.PP
34.I Fgets
35reads
36.IR n \-1
92e5df88 37characters, or up through a newline
2e146d0b
KM
38character, whichever comes first,
39from the
40.I stream
41into the string
42.IR s .
43The last character read into
44.I s
45is followed by a null character.
46.I Fgets
47returns its first argument.
48.SH "SEE ALSO"
9ecd5650
KM
49puts(3S),
50getc(3S),
51scanf(3S),
52fread(3S),
53ferror(3S)
2e146d0b
KM
54.SH DIAGNOSTICS
55.I Gets
56and
57.I fgets
58return the constant pointer
59.SM
60.B NULL
61upon end of file or error.
62.SH BUGS
63.I Gets
64deletes a newline,
65.I fgets
66keeps it,
67all in the name of backward compatibility.