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