nightly: remove unused BINARCHIVE
[unleashed.git] / share / man / man3c / gets.3c
blob08b290f586b187ebf8c24ecfbd51d8f9b9ca0a5b
1 '\" te
2 .\" Copyright 1989 AT&T.  Copyright (c) 2003, Sun Microsystems, Inc.  All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH GETS 3C "Oct 15, 2003"
7 .SH NAME
8 gets, fgets \- get a string from a stream
9 .SH SYNOPSIS
10 .LP
11 .nf
12 #include <stdio.h>
14 \fBchar *\fR\fBgets\fR(\fBchar *\fR\fIs\fR);
15 .fi
17 .LP
18 .nf
19 \fBchar *\fR\fBfgets\fR(\fBchar *\fR\fIs\fR, \fBint\fR \fIn\fR, \fBFILE *\fR\fIstream\fR);
20 .fi
22 .SH DESCRIPTION
23 .sp
24 .LP
25 The \fBgets()\fR function reads bytes from the standard input stream (see
26 \fBIntro\fR(3)), \fBstdin\fR, into the array pointed to by \fIs\fR, until a
27 newline character is read or an end-of-file condition is encountered. The
28 newline character is discarded and the string is terminated with a null byte.
29 .sp
30 .LP
31 If the length of an input line exceeds the size of \fIs\fR, indeterminate
32 behavior may result. For this reason, it is strongly recommended that
33 \fBgets()\fR be avoided in favor of \fBfgets()\fR.
34 .sp
35 .LP
36 The \fBfgets()\fR function reads bytes from the \fIstream\fR into the array
37 pointed to by \fIs\fR, until \fIn\fR\(mi1 bytes are read, or a newline
38 character is read and transferred to \fIs\fR, or an end-of-file condition is
39 encountered. The string is then terminated with a null byte.
40 .sp
41 .LP
42 The \fBfgets()\fR and \fBgets()\fR functions may mark the \fBst_atime\fR field
43 of the file associated with \fIstream\fR for update. The \fBst_atime\fR field
44 will be marked for update by the first successful execution of \fBfgetc\fR(3C),
45 \fBfgets()\fR, \fBfread\fR(3C), \fBfscanf\fR(3C), \fBgetc\fR(3C),
46 \fBgetchar\fR(3C), \fBgets()\fR, or \fBscanf\fR(3C) using \fIstream\fR that
47 returns data not supplied by a prior call to \fBungetc\fR(3C) or
48 \fBungetwc\fR(3C).
49 .SH RETURN VALUES
50 .sp
51 .LP
52 If end-of-file is encountered and no bytes have been read, no bytes are
53 transferred to \fIs\fR and a null pointer is returned. For standard-conforming
54 (see \fBstandards\fR(5)) applications, if the end-of-file indicator for the
55 stream is set, no bytes are transferred to \fIs\fR and a null pointer is
56 returned whether or not the stream is at end-of-file. If a read error occurs,
57 such as trying to use these functions on a file that has not been opened for
58 reading, a null pointer is returned and the error indicator for the stream is
59 set. If end-of-file is encountered, the \fBEOF\fR indicator for the stream is
60 set.  Otherwise \fIs\fR is returned.
61 .SH ERRORS
62 .sp
63 .LP
64 Refer to \fBfgetc\fR(3C).
65 .SH ATTRIBUTES
66 .sp
67 .LP
68 See \fBattributes\fR(5) for descriptions of the following attributes:
69 .sp
71 .sp
72 .TS
73 box;
74 c | c
75 l | l .
76 ATTRIBUTE TYPE  ATTRIBUTE VALUE
78 Interface Stability     Standard
80 MT-Level        MT-Safe
81 .TE
83 .SH SEE ALSO
84 .sp
85 .LP
86 \fBlseek\fR(2), \fBread\fR(2), \fBferror\fR(3C), \fBfgetc\fR(3C),
87 \fBfgetwc\fR(3C), \fBfopen\fR(3C), \fBfread\fR(3C), \fBgetchar\fR(3C),
88 \fBscanf\fR(3C), \fBstdio\fR(3C), \fBungetc\fR(3C), \fBungetwc\fR(3C),
89 \fBattributes\fR(5), \fBstandards\fR(5)