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