1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
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.
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.
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
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" Modified Wed Jul 28 11:12:07 1993 by Rik Faith (faith@cs.unc.edu)
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>
32 .TH GETS 3 2008-08-06 "GNU" "Linux Programmer's Manual"
35 .\"O fgetc, fgets, getc, getchar, gets, ungetc \- input of characters and strings
36 fgetc, fgets, getc, getchar, gets, ungetc \- ʸ»ú¤Èʸ»úÎó¤ÎÆþÎÏ
42 .BI "int fgetc(FILE *" stream );
44 .BI "char *fgets(char *" "s" ", int " "size" ", FILE *" "stream" );
46 .BI "int getc(FILE *" stream );
48 .B "int getchar(void);"
50 .BI "char *gets(char *" "s" );
52 .BI "int ungetc(int " c ", FILE *" stream );
57 .\"O reads the next character from
59 .\"O and returns it as an
65 .\"O on end of file or error.
73 ¤Ë¥¥ã¥¹¥È¤·¤ÆÊÖ¤¹¡£¥Õ¥¡¥¤¥ë¤Î½ª¤ï¤ê¤ä¥¨¥é¡¼¤È¤Ê¤Ã¤¿¾ì¹ç¤Ï
80 .\"O except that it may be implemented as a macro which evaluates
88 ¤òÊ£¿ô²óɾ²Á¤¹¤ë¥Þ¥¯¥í¤È¤·¤Æ¼ÂÁõ¤µ¤ì¤Æ¤¤¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
92 .\"O .BI "getc(" stdin ) \fR.
95 .BI "getc(" stdin ) \fR
99 .\"O reads a line from
101 .\"O into the buffer pointed to by
103 .\"O until either a terminating newline or
105 .\"O which it replaces with
106 .\"O .BR \(aq\e0\(aq .
114 ¤¬»Ø¤¹¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤¹¤ë
120 .\"O No check for buffer overrun is performed (see BUGS below).
121 ¥Ð¥Ã¥Õ¥¡¡¦¥ª¡¼¥Ð¡¼¥é¥ó¤Î¥Á¥§¥Ã¥¯¤Ï¹Ô¤ï¤ì¤Ê¤¤ (²¼µ¤Î¡Ö¥Ð¥°¡×¤ò»²¾È)¡£
124 .\"O reads in at most one less than
128 .\"O and stores them into the buffer pointed to by
130 .\"O Reading stops after an
133 .\"O If a newline is read, it is stored into the buffer.
136 .\"O is stored after the last character in the buffer.
144 ¤¬»Ø¤¹¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤¹¤ë¡£Æɤ߹þ¤ß¤Ï
146 ¤Þ¤¿¤Ï²þ¹Ôʸ»ú¤òÆɤ߹þ¤ó¤À¸å¤ÇÄä»ß¤¹¤ë¡£
147 Æɤ߹þ¤Þ¤ì¤¿²þ¹Ôʸ»ú¤Ï¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤µ¤ì¤ë¡£
149 ʸ»ú¤¬°ì¤Ä¥Ð¥Ã¥Õ¥¡¤ÎÃæ¤ÎºÇ¸å¤Îʸ»ú¤Î¸å¤Ë½ñ¤¹þ¤Þ¤ì¤ë¡£
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.
162 ¤Ï¡¢¸å¤Î read Áàºî¤ÇÆɤá¤ë¤è¤¦¤Ë¡¢
169 ½ñ¤Ìᤵ¤ì¤¿Ê¸»ú¤ÏµÕ½ç¤ËÌᤵ¤ì¤ë;
170 ½ñ¤Ìᤷ¤È¤·¤ÆÊݾڤµ¤ì¤Æ¤¤¤ë¤Î¤Ï¡¢°ìʸ»ú¤À¤±¤Ç¤¢¤ë¡£
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
175 .\"O library for the same input stream.
178 ¥é¥¤¥Ö¥é¥ê¤ÎÆþÎÏ´Ø¿ô¤òƱ¤¸ÆþÎÏ¥¹¥È¥ê¡¼¥à¤ËÂФ·¤Æ¸ß¤¤¤Ëº®¤¼¤Æ»È¤¦¤³¤È¤¬¤Ç¤¤ë¡£
180 .\"O For nonlocking counterparts, see
181 .\"O .BR unlocked_stdio (3).
182 ¤³¤ì¤é¤Î½èÍý¤ò¥í¥Ã¥¯¤»¤º¤Ë¹Ô¤¤¤¿¤¤¤È¤¤Ï¡¢
183 .BR unlocked_stdio (3)
185 .\"O .SH "RETURN VALUES"
191 .\"O return the character read as an
192 .\"O .I unsigned char
197 .\"O on end of file or error.
205 ¤Ë¥¥ã¥¹¥È¤·¤ÆÊÖ¤¹¡£¥Õ¥¡¥¤¥ë¤Î½ª¤ï¤ê¤ä¥¨¥é¡¼¤Î¾ì¹ç¤Ï
214 .\"O on success, and NULL
215 .\"O on error or when end of file occurs while no characters have been read.
221 ¤òÊÖ¤·¡¢¥¨¥é¡¼¤ä 1 ʸ»ú¤âÆɤ߹þ¤ó¤Ç¤¤¤Ê¤¤¤Î¤Ë¥Õ¥¡¥¤¥ë¤Î½ª¤ï¤ê¤Ë¤Ê¤Ã¤¿
233 ¤òÊÖ¤·¡¢¥¨¥é¡¼¤Î¾ì¹ç¤Ï
236 .\"O .SH "CONFORMS TO"
238 C89, C99, POSIX.1-2001.
244 .\"O POSIX.1-2008 removes the specification of
248 ¤Î»ÅÍͤ¬ºï½ü¤µ¤ì¤Æ¤¤¤ë¡£
253 .\"O Because it is impossible to tell without knowing the data in advance how many
256 .\"O will read, and because
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.
265 ¤ÏÀäÂФ˻ÈÍѤ·¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
266 Á°¤â¤Ã¤Æ¥Ç¡¼¥¿¤òÃΤ뤳¤È¤Ê¤·¤Ë
268 ¤¬²¿Ê¸»úÆɤफ¤òÃΤ뤳¤È¤Ï¤Ç¤¤º¡¢
270 ¤¬¥Ð¥Ã¥Õ¥¡¤Î½ª¤ï¤ê¤ò±Û¤¨¤Æ½ñ¤¹þ¤ß³¤±¤ë¤¿¤á¡¢
272 ¤ò»È¤¦¤Î¤Ï¶Ë¤á¤Æ´í¸±¤Ç¤¢¤ë¡£
273 ¤³¤ì¤òÍøÍѤ·¤Æ¥³¥ó¥Ô¥å¡¼¥¿¤Î¥»¥¥å¥ê¥Æ¥£¤¬Çˤé¤ì¤Æ¤¤¿¡£
278 .\"O It is not advisable to mix calls to input functions from the
280 .\"O library with low-level calls to
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 ÆþÎÏ¥¹¥È¥ê¡¼¥à¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ËÂФ·¤Æ¡¢
286 ¥é¥¤¥Ö¥é¥ê¤ÎÆþÎÏ´Ø¿ô¤È¡¢Äã¥ì¥Ù¥ë¸Æ¤Ó½Ð¤·¤Î
288 ¤òº®¤¼¤Æ¸Æ¤Ó½Ð¤¹»ö¤Ï´«¤á¤é¤ì¤Ê¤¤¡£
289 ·ë²Ì¤¬¤É¤¦¤Ê¤ë¤«¤Ïʬ¤«¤é¤º¡¢¤ª¤½¤é¤¯¤¢¤Ê¤¿¤Î
290 ˾¤ó¤Ç¤¤¤ë·ë²Ì¤Ë¤Ï¤Ê¤é¤Ê¤¤¤À¤í¤¦¡£
306 .BR unlocked_stdio (3)