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