| Line | |
|---|
| 1 | .\" @(#)gets.3s 6.1 (Berkeley) 5/15/85
|
|---|
| 2 | .\"
|
|---|
| 3 | .TH GETS 3 "May 15, 1985"
|
|---|
| 4 | .AT 3
|
|---|
| 5 | .SH NAME
|
|---|
| 6 | gets, fgets \- get a string from a stream
|
|---|
| 7 | .SH SYNOPSIS
|
|---|
| 8 | .nf
|
|---|
| 9 | .ft B
|
|---|
| 10 | #include <stdio.h>
|
|---|
| 11 |
|
|---|
| 12 | char *gets(char *\fIs\fP)
|
|---|
| 13 | char *fgets(char *\fIs\fP, int \fIn\fP, FILE *\fIstream\fP)
|
|---|
| 14 | .ft R
|
|---|
| 15 | .fi
|
|---|
| 16 | .SH DESCRIPTION
|
|---|
| 17 | .B Gets
|
|---|
| 18 | reads a string into
|
|---|
| 19 | .I s
|
|---|
| 20 | from the standard input stream
|
|---|
| 21 | .BR stdin .
|
|---|
| 22 | The string is terminated by a newline
|
|---|
| 23 | character, which is replaced in
|
|---|
| 24 | .I s
|
|---|
| 25 | by a null character.
|
|---|
| 26 | .B Gets
|
|---|
| 27 | returns its argument.
|
|---|
| 28 | .PP
|
|---|
| 29 | .B Fgets
|
|---|
| 30 | reads
|
|---|
| 31 | .IR n \-1
|
|---|
| 32 | characters, or up through a newline
|
|---|
| 33 | character, whichever comes first,
|
|---|
| 34 | from the
|
|---|
| 35 | .I stream
|
|---|
| 36 | into the string
|
|---|
| 37 | .IR s .
|
|---|
| 38 | The last character read into
|
|---|
| 39 | .I s
|
|---|
| 40 | is followed by a null character.
|
|---|
| 41 | .B Fgets
|
|---|
| 42 | returns its first argument.
|
|---|
| 43 | .SH "SEE ALSO"
|
|---|
| 44 | .BR puts (3),
|
|---|
| 45 | .BR getc (3),
|
|---|
| 46 | .BR scanf (3),
|
|---|
| 47 | .BR fread (3),
|
|---|
| 48 | .BR ferror (3).
|
|---|
| 49 | .SH DIAGNOSTICS
|
|---|
| 50 | .B Gets
|
|---|
| 51 | and
|
|---|
| 52 | .B fgets
|
|---|
| 53 | return the constant pointer
|
|---|
| 54 | .SM
|
|---|
| 55 | .B NULL
|
|---|
| 56 | upon end of file or error.
|
|---|
| 57 | .SH BUGS
|
|---|
| 58 | .B Gets
|
|---|
| 59 | deletes a newline,
|
|---|
| 60 | .B fgets
|
|---|
| 61 | keeps it,
|
|---|
| 62 | all in the name of backward compatibility.
|
|---|
| 63 | .PP
|
|---|
| 64 | .B Gets
|
|---|
| 65 | is not present in the Minix-vmd C library for reasons that should be obvious.
|
|---|
| 66 | Use
|
|---|
| 67 | .B fgets
|
|---|
| 68 | instead.
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.