Commit | Line | Data |
---|---|---|
2e146d0b KM |
1 | .\" @(#)gets.3 4.1 (Berkeley) %G% |
2 | .\" | |
3 | .TH GETS 3S | |
4 | .AT 3 | |
5 | .SH NAME | |
6 | gets, 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 | |
23 | reads a string into | |
24 | .I s | |
25 | from the standard input stream | |
26 | .B stdin. | |
27 | The string is terminated by a newline | |
28 | character, which is replaced in | |
29 | .I s | |
30 | by a null character. | |
31 | .I Gets | |
32 | returns its argument. | |
33 | .PP | |
34 | .I Fgets | |
35 | reads | |
36 | .IR n \-1 | |
37 | characters, or up to a newline | |
38 | character, whichever comes first, | |
39 | from the | |
40 | .I stream | |
41 | into the string | |
42 | .IR s . | |
43 | The last character read into | |
44 | .I s | |
45 | is followed by a null character. | |
46 | .I Fgets | |
47 | returns its first argument. | |
48 | .SH "SEE ALSO" | |
49 | puts(3), | |
50 | getc(3), scanf(3), fread(3), | |
51 | ferror(3) | |
52 | .SH DIAGNOSTICS | |
53 | .I Gets | |
54 | and | |
55 | .I fgets | |
56 | return the constant pointer | |
57 | .SM | |
58 | .B NULL | |
59 | upon end of file or error. | |
60 | .SH BUGS | |
61 | .I Gets | |
62 | deletes a newline, | |
63 | .I fgets | |
64 | keeps it, | |
65 | all in the name of backward compatibility. |