OSDN Git Service

(split) Import translated manuals from JM CVS Repository.
[linuxjm/LDP_man-pages.git] / draft / man3 / gets.3
1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\" License.
23 .\" Modified Wed Jul 28 11:12:07 1993 by Rik Faith (faith@cs.unc.edu)
24 .\"
25 .\" Japanese Version Copyright (c) 1997 IMAMURA Nobutaka
26 .\"         all rights reserved.
27 .\" Translated 1997-02-14, IMAMURA Nobutaka <imamura@spp.hpc.fujitsu.co.jp>
28 .\" Updated 1999-08-29, Kentaro Shirakata <argrath@ub32.org>
29 .\" Updated 2001-11-02, Kentaro Shirakata <argrath@ub32.org>
30 .\" Updated 2005-09-06, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
31 .\"
32 .TH GETS 3  2008-08-06 "GNU" "Linux Programmer's Manual"
33 .\"O .SH NAME
34 .SH Ì¾Á°
35 .\"O fgetc, fgets, getc, getchar, gets, ungetc \- input of characters and strings
36 fgetc, fgets, getc, getchar, gets, ungetc \- Ê¸»ú¤Èʸ»úÎó¤ÎÆþÎÏ
37 .\"O .SH SYNOPSIS
38 .SH ½ñ¼°
39 .nf
40 .B #include <stdio.h>
41 .sp
42 .BI "int fgetc(FILE *" stream );
43
44 .BI "char *fgets(char *" "s" ", int " "size" ", FILE *" "stream" );
45
46 .BI "int getc(FILE *" stream );
47
48 .B "int getchar(void);"
49
50 .BI "char *gets(char *" "s" );
51
52 .BI "int ungetc(int " c ", FILE *" stream );
53 .fi
54 .\"O .SH DESCRIPTION
55 .SH ÀâÌÀ
56 .\"O .BR fgetc ()
57 .\"O reads the next character from
58 .\"O .I stream
59 .\"O and returns it as an
60 .\"O .I unsigned char
61 .\"O cast to an
62 .\"O .IR int ,
63 .\"O or
64 .\"O .B EOF
65 .\"O on end of file or error.
66 .BR fgetc ()
67 ¤Ï¡¢
68 .I stream
69 ¤«¤é¼¡¤Îʸ»ú¤ò
70 .I unsigned char
71 ¤È¤·¤ÆÆɤߡ¢
72 .I int
73 ¤Ë¥­¥ã¥¹¥È¤·¤ÆÊÖ¤¹¡£¥Õ¥¡¥¤¥ë¤Î½ª¤ï¤ê¤ä¥¨¥é¡¼¤È¤Ê¤Ã¤¿¾ì¹ç¤Ï
74 .B EOF
75 ¤òÊÖ¤¹¡£
76 .PP
77 .\"O .BR getc ()
78 .\"O is equivalent to
79 .\"O .BR fgetc ()
80 .\"O except that it may be implemented as a macro which evaluates
81 .\"O .I stream
82 .\"O more than once.
83 .BR getc ()
84 ¤Ï
85 .BR fgetc ()
86 ¤ÈƱÍͤÀ¤¬¡¢
87 .I stream
88 ¤òÊ£¿ô²óɾ²Á¤¹¤ë¥Þ¥¯¥í¤È¤·¤Æ¼ÂÁõ¤µ¤ì¤Æ¤¤¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
89 .PP
90 .\"O .BR getchar ()
91 .\"O is equivalent to
92 .\"O .BI "getc(" stdin ) \fR.
93 .BR getchar ()
94 ¤Ï
95 .BI "getc(" stdin ) \fR
96 ¤ÈƱ¤¸¤Ç¤¢¤ë¡£
97 .PP
98 .\"O .BR gets ()
99 .\"O reads a line from
100 .\"O .I stdin
101 .\"O into the buffer pointed to by
102 .\"O .I s
103 .\"O until either a terminating newline or
104 .\"O .BR EOF ,
105 .\"O which it replaces with
106 .\"O .BR \(aq\e0\(aq .
107 .BR gets ()
108 ¤Ï¡¢²þ¹Ôʸ»ú¤«
109 .B EOF
110 ¤Þ¤Ç¤Î 1¹Ô¤ò
111 .I stdin
112 ¤«¤éÆɤ߹þ¤ß
113 .I s
114 ¤¬»Ø¤¹¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤¹¤ë
115 (ËöÈø¤Î²þ¹Ôʸ»ú¤ä
116 .B EOF
117 ¤Ï
118 .B \(aq\e0\(aq
119 ¤ËÃÖ¤­´¹¤¨¤é¤ì¤ë)¡£
120 .\"O No check for buffer overrun is performed (see BUGS below).
121 ¥Ð¥Ã¥Õ¥¡¡¦¥ª¡¼¥Ð¡¼¥é¥ó¤Î¥Á¥§¥Ã¥¯¤Ï¹Ô¤ï¤ì¤Ê¤¤ (²¼µ­¤Î¡Ö¥Ð¥°¡×¤ò»²¾È)¡£
122 .PP
123 .\"O .BR fgets ()
124 .\"O reads in at most one less than
125 .\"O .I size
126 .\"O characters from
127 .\"O .I stream
128 .\"O and stores them into the buffer pointed to by
129 .\"O .IR s .
130 .\"O Reading stops after an
131 .\"O .B EOF
132 .\"O or a newline.
133 .\"O If a newline is read, it is stored into the buffer.
134 .\"O A
135 .\"O .B \(aq\e0\(aq
136 .\"O is stored after the last character in the buffer.
137 .BR fgets ()
138 ¤Ï
139 .I stream
140 ¤«¤éºÇÂç¤Ç
141 .IR size " - 1"
142 ¸Ä¤Îʸ»ú¤òÆɤ߹þ¤ß¡¢
143 .I s
144 ¤¬»Ø¤¹¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤¹¤ë¡£Æɤ߹þ¤ß¤Ï
145 .B EOF
146 ¤Þ¤¿¤Ï²þ¹Ôʸ»ú¤òÆɤ߹þ¤ó¤À¸å¤ÇÄä»ß¤¹¤ë¡£
147 Æɤ߹þ¤Þ¤ì¤¿²þ¹Ôʸ»ú¤Ï¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤µ¤ì¤ë¡£
148 .B \(aq\e0\(aq
149 ʸ»ú¤¬°ì¤Ä¥Ð¥Ã¥Õ¥¡¤ÎÃæ¤ÎºÇ¸å¤Îʸ»ú¤Î¸å¤Ë½ñ¤­¹þ¤Þ¤ì¤ë¡£
150 .PP
151 .\"O .BR ungetc ()
152 .\"O pushes
153 .\"O .I c
154 .\"O back to
155 .\"O .IR stream ,
156 .\"O cast to
157 .\"O .IR "unsigned char" ,
158 .\"O where it is available for subsequent read operations.
159 .\"O Pushed-back characters
160 .\"O will be returned in reverse order; only one pushback is guaranteed.
161 .BR ungetc ()
162 ¤Ï¡¢¸å¤Î read Áàºî¤ÇÆɤá¤ë¤è¤¦¤Ë¡¢
163 .I c
164 ¤ò
165 .I "unsigned char"
166 ¤Ë¥­¥ã¥¹¥È¤·¤Æ
167 .I stream
168 ¤Ë½ñ¤­Ì᤹¡£
169 ½ñ¤­Ìᤵ¤ì¤¿Ê¸»ú¤ÏµÕ½ç¤ËÌᤵ¤ì¤ë;
170 ½ñ¤­Ìᤷ¤È¤·¤ÆÊݾڤµ¤ì¤Æ¤¤¤ë¤Î¤Ï¡¢°ìʸ»ú¤À¤±¤Ç¤¢¤ë¡£
171 .PP
172 .\"O Calls to the functions described here can be mixed with each other and with
173 .\"O calls to other input functions from the
174 .\"O .I stdio
175 .\"O library for the same input stream.
176 ¤³¤³¤Ç½Ò¤Ù¤¿´Ø¿ô¤ä
177 .I stdio
178 ¥é¥¤¥Ö¥é¥ê¤ÎÆþÎÏ´Ø¿ô¤òƱ¤¸ÆþÎÏ¥¹¥È¥ê¡¼¥à¤ËÂФ·¤Æ¸ß¤¤¤Ëº®¤¼¤Æ»È¤¦¤³¤È¤¬¤Ç¤­¤ë¡£
179 .PP
180 .\"O For nonlocking counterparts, see
181 .\"O .BR unlocked_stdio (3).
182 ¤³¤ì¤é¤Î½èÍý¤ò¥í¥Ã¥¯¤»¤º¤Ë¹Ô¤¤¤¿¤¤¤È¤­¤Ï¡¢
183 .BR unlocked_stdio (3)
184 ¤ò»²¾È¤Î¤³¤È¡£
185 .\"O .SH "RETURN VALUES"
186 .SH ÊÖ¤êÃÍ
187 .\"O .BR fgetc (),
188 .\"O .BR getc ()
189 .\"O and
190 .\"O .BR getchar ()
191 .\"O return the character read as an
192 .\"O .I unsigned char
193 .\"O cast to an
194 .\"O .I int
195 .\"O or
196 .\"O .B EOF
197 .\"O on end of file or error.
198 .BR fgetc (),
199 .BR getc (),
200 .BR getchar ()
201 ¤Ï¡¢Ê¸»ú¤ò
202 .I unsigned char
203 ¤È¤·¤ÆÆɤó¤Ç
204 .I int
205 ¤Ë¥­¥ã¥¹¥È¤·¤ÆÊÖ¤¹¡£¥Õ¥¡¥¤¥ë¤Î½ª¤ï¤ê¤ä¥¨¥é¡¼¤Î¾ì¹ç¤Ï
206 .B EOF
207 ¤òÊÖ¤¹¡£
208 .PP
209 .\"O .BR gets ()
210 .\"O and
211 .\"O .BR fgets ()
212 .\"O return
213 .\"O .I s
214 .\"O on success, and NULL
215 .\"O on error or when end of file occurs while no characters have been read.
216 .BR gets ()
217 ¤È
218 .BR fgets ()
219 ¤Ï¡¢À®¸ù¤¹¤ë¤È
220 .I s
221 ¤òÊÖ¤·¡¢¥¨¥é¡¼¤ä 1 Ê¸»ú¤âÆɤ߹þ¤ó¤Ç¤¤¤Ê¤¤¤Î¤Ë¥Õ¥¡¥¤¥ë¤Î½ª¤ï¤ê¤Ë¤Ê¤Ã¤¿
222 ¾ì¹ç¤Ë NULL ¤òÊÖ¤¹¡£
223 .PP
224 .\"O .BR ungetc ()
225 .\"O returns
226 .\"O .I c
227 .\"O on success, or
228 .\"O .B EOF
229 .\"O on error.
230 .BR ungetc ()
231 ¤ÏÀ®¸ù¤¹¤ë¤È
232 .I c
233 ¤òÊÖ¤·¡¢¥¨¥é¡¼¤Î¾ì¹ç¤Ï
234 .B EOF
235 ¤òÊÖ¤¹¡£
236 .\"O .SH "CONFORMS TO"
237 .SH ½àµò
238 C89, C99, POSIX.1-2001.
239 .\"O LSB deprecates
240 .\"O .BR gets ().
241 LSB ¤Ç¤Ï
242 .BR gets ()
243 ¤ÏÈó¿ä¾©¤Ç¤¢¤ë¡£
244 .\"O POSIX.1-2008 removes the specification of
245 .\"O .BR gets ().
246 POSIX.1-2008 ¤Ç¤Ï
247 .BR gets ()
248 ¤Î»ÅÍͤ¬ºï½ü¤µ¤ì¤Æ¤¤¤ë¡£
249 .\"O .SH "BUGS"
250 .SH ¥Ð¥°
251 .\"O Never use
252 .\"O .BR gets ().
253 .\"O Because it is impossible to tell without knowing the data in advance how many
254 .\"O characters
255 .\"O .BR gets ()
256 .\"O will read, and because
257 .\"O .BR gets ()
258 .\"O will continue to store characters past the end of the buffer,
259 .\"O it is extremely dangerous to use.
260 .\"O It has been used to break computer security.
261 .\"O Use
262 .\"O .BR fgets ()
263 .\"O instead.
264 .BR gets ()
265 ¤ÏÀäÂФ˻ÈÍѤ·¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
266 Á°¤â¤Ã¤Æ¥Ç¡¼¥¿¤òÃΤ뤳¤È¤Ê¤·¤Ë
267 .BR gets ()
268 ¤¬²¿Ê¸»úÆɤफ¤òÃΤ뤳¤È¤Ï¤Ç¤­¤º¡¢
269 .BR gets ()
270 ¤¬¥Ð¥Ã¥Õ¥¡¤Î½ª¤ï¤ê¤ò±Û¤¨¤Æ½ñ¤­¹þ¤ß³¤±¤ë¤¿¤á¡¢
271 .BR gets ()
272 ¤ò»È¤¦¤Î¤Ï¶Ë¤á¤Æ´í¸±¤Ç¤¢¤ë¡£
273 ¤³¤ì¤òÍøÍѤ·¤Æ¥³¥ó¥Ô¥å¡¼¥¿¤Î¥»¥­¥å¥ê¥Æ¥£¤¬Çˤé¤ì¤Æ¤­¤¿¡£
274 Âå¤ï¤ê¤Ë
275 .BR fgets ()
276 ¤ò»È¤¦¤³¤È¡£
277 .PP
278 .\"O It is not advisable to mix calls to input functions from the
279 .\"O .I stdio
280 .\"O library with low-level calls to
281 .\"O .BR read (2)
282 .\"O for the file descriptor associated with the input stream; the results
283 .\"O will be undefined and very probably not what you want.
284 ÆþÎÏ¥¹¥È¥ê¡¼¥à¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ËÂФ·¤Æ¡¢
285 .I stdio
286 ¥é¥¤¥Ö¥é¥ê¤ÎÆþÎÏ´Ø¿ô¤È¡¢Äã¥ì¥Ù¥ë¸Æ¤Ó½Ð¤·¤Î
287 .BR read (2)
288 ¤òº®¤¼¤Æ¸Æ¤Ó½Ð¤¹»ö¤Ï´«¤á¤é¤ì¤Ê¤¤¡£
289 ·ë²Ì¤¬¤É¤¦¤Ê¤ë¤«¤Ïʬ¤«¤é¤º¡¢¤ª¤½¤é¤¯¤¢¤Ê¤¿¤Î
290 ˾¤ó¤Ç¤¤¤ë·ë²Ì¤Ë¤Ï¤Ê¤é¤Ê¤¤¤À¤í¤¦¡£
291 .\"O .SH "SEE ALSO"
292 .SH ´ØÏ¢¹àÌÜ
293 .BR read (2),
294 .BR write (2),
295 .BR ferror (3),
296 .BR fgetwc (3),
297 .BR fgetws (3),
298 .BR fopen (3),
299 .BR fread (3),
300 .BR fseek (3),
301 .BR getline (3),
302 .BR getwchar (3),
303 .BR puts (3),
304 .BR scanf (3),
305 .BR ungetwc (3),
306 .BR unlocked_stdio (3)