BSD 3 development
[unix-history] / usr / man / man3 / gets.3s
CommitLineData
e6817382
BJ
1.TH GETS 3S
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.B 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(3),
47getc(3), scanf(3), fread(3),
48ferror(3)
49.SH DIAGNOSTICS
50.I Gets
51and
52.I fgets
53return the constant pointer
54.SM
55.B NULL
56upon end of file or error.
57.SH BUGS
58.I Gets
59deletes a newline,
60.I fgets
61keeps it,
62all in the name of backward compatibility.