manual page distributed with 4.1BSD
[unix-history] / usr / src / lib / libc / stdio / gets.3
CommitLineData
2e146d0b
KM
1.\" @(#)gets.3 4.1 (Berkeley) %G%
2.\"
3.TH GETS 3S
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
26.B stdin.
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
37characters, or up to a newline
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"
49puts(3),
50getc(3), scanf(3), fread(3),
51ferror(3)
52.SH DIAGNOSTICS
53.I Gets
54and
55.I fgets
56return the constant pointer
57.SM
58.B NULL
59upon end of file or error.
60.SH BUGS
61.I Gets
62deletes a newline,
63.I fgets
64keeps it,
65all in the name of backward compatibility.