.\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" This code is derived from software contributed to Berkeley by .\" Chris Torek and the American National Standards Committee X3, .\" on Information Processing Systems. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#) fgets. 3 8.1 (Berkeley) 6/4/93 .\" .\" %FreeBSD: src/lib/libc/stdio/fgets. 3, v 1.6. 2.6 2001/12/14 18:33:57 ru Exp % .\" $FreeBSD: doc/ja_JP.eucJP/man/man3/fgets. 3, v 1.5 2002/05/18 07:12:54 horikawa Exp $ .\" .Dd June 4, 1993 .Dt FGETS 3 .Os .Sh ¸íĪ .Nm fgets , .Nm gets .Nd ½ºÆ®¸²·ÎºÎÅÍ ÇàÀ» Ãëµæ .Sh ¼­½Ä .In stdio.h .Ft char * .Fn fgets "char *str" "int size" "FILE *stream" .Ft char * .Fn gets "char *str" .Sh ÇØ¼³ .Fn fgets ÇÔ¼ö´Â, ÃÖ´ë·Î .Fa size ±×¸®°í ÁöÁ¤µÈ ij¸¯ÅͼöºÎÅÍ 1 ¸¸ ÀûÀº ¼öÀÇ Ä³¸¯Å͸¦ .Fa stream (À¸)·ÎºÎÅÍ Àоîµé¿©, ij¸¯ÅÍ ¶óÀÎ .Fa str ¿¡ º¸Á¸ÇÕ´Ï´Ù. µ¶Æ÷ÇÔÀº, °³Çà ij¸¯ÅͰ¡ ¹ß°ßµÇ°Å³ª ÆÄÀÏÀÇ Á¾·á ȤÀº ¿¡·¯°¡ ¹ß°ßµÇ°Å³ª ÇßÀ» °æ¿ì¿¡ Á¤ÁöÇÕ´Ï´Ù. °³Çà ij¸¯ÅÍ´Â, Á¸ÀçÇϰí ÀÖÀ¸¸é º¸°ü À¯ÁöµË´Ï´Ù. ÀÓÀÇÀÇ Ä³¸¯Å͸¦ Àоîµé¿© ¿¡·¯°¡ ¹ß»ýÇÏÁö ¾Ê¾Ò´ø °æ¿ì, ij¸¯ÅÍ ¶óÀÎÀÇ ¸¶Áö¸·¿¡´Â .Ql \e0 ij¸¯ÅͰ¡ Ãß°¡µË´Ï´Ù. .Pp .Fn gets ÇÔ¼ö´Â .Fn fgets ÇÔ¼ö·Î .Fa size (À»)¸¦ ¹«ÇÑÇÏ°Ô ÇØ, .Em stdin (À»)¸¦ .Fa stream (À¸)·Î ÇÑ °Í°ú µî°¡ÀÔ´Ï´Ù¸¸, ij¸¯ÅÍ ¶óÀÎÁß¿¡¼­ °³Çà ij¸¯ÅͰ¡ º¸Á¸µÇÁö ¾Ê´Â (°³Çà ij¸¯ÅͰ¡ Á¸ÀçÇßÀ» °æ¿ì) Á¡ÀÌ ´Ù¸¨´Ï´Ù. ÀÔ·ÂÇàÀÌ Á¸ÀçÇÏ´Â °æ¿ì, ±×°ÍÀÌ ÃæºÐÈ÷ ª°Ô ij¸¯ÅÍ ¶óÀο¡ ¿ÏÀüÈ÷ ÇØ°áµÈ´Ù ÀÏÀ» ÇÁ·ÎÅØ¼ÇÇÏ´Â °ÍÀº È£ÃâÃøÀÇ Ã¥ÀÓÀÔ´Ï´Ù. .Sh ¹Ýȯ°ª Á¤»ó Á¾·áÇϸé(ÀÚ), .Fn fgets (¿Í)°ú .Fn gets (Àº)´Â ij¸¯ÅÍ ¶óÀÎÀÇ Æ÷ÀÎÅ͸¦ µÇµ¹¸³´Ï´Ù. ij¸¯Å͸¦ ÀоîµéÀ̱â Àü¿¡ ÆÄÀÏÀÇ Á¾·á¿¡ À̸£¸é(ÀÚ), .Dv NULL ÇÏÁö¸¸ µÇµ¹·ÁÁý´Ï´Ù. ÀÌ °æ¿ì, ¹öÆÛÀÇ ³»¿ëÀº º¯È­ÇÏÁö ¾Ê½À´Ï´Ù. ¿¡·¯°¡ ¹ß»ýÇϸé(ÀÚ) .Dv NULL ÇÏÁö¸¸ µÇµ¹·ÁÁ® ¹öÆÛÀÇ ³»¿ëÀº ºÎÁ¤ÀÌ µË´Ï´Ù. .Fn fgets ÇÔ¼ö¿Í .Fn gets ÇÔ¼ö´Â ÆÄÀÏÀÇ Á¾·á¿Í ¿¡·¯¸¦ ±¸º°ÇÏÁö ¾Ê½À´Ï´Ù. ÆÄÀÏÀÇ Á¾·áÀΰ¡ ¿¡·¯ÀÎÁö¸¦ ÆÇ´ÜÇÏ·Á¸é , È£ÃâÃøÀÌ .Xr feof 3 (¿Í)°ú .Xr ferror 3 (À»)¸¦ »ç¿ëÇÏÁö ¾ÊÀ¸¸é ¾ÈµË´Ï´Ù. .Sh ¿¡·¯ .Bl -tag -width Er .It Bq Er EBADF ÁöÁ¤µÇ¾ú´Ù .Fa stream ÇÏÁö¸¸, µ¶ ºÕºñ¾î °¡´ÉÇÑ ½ºÆ®¸²ÀÌ ¾Æ´Õ´Ï´Ù. .El .Pp .Fn fgets ÇÔ¼ö°¡ ¿¡·¯°¡ µÇ¸é(ÀÚ), routine .Xr fflush 3 , .Xr fstat 2 , .Xr read 2 , .Xr malloc 3 ¿ëÀ¸·Î ÁöÁ¤µÈ ¿¡·¯Áß ÇÑÂÊÀÌ .Va errno (À¸)·Î ¼³Á¤µÇ´Â °æ¿ì°¡ ÀÖ½À´Ï´Ù. .Pp .Fn gets ÇÔ¼ö°¡ ¿¡·¯°¡ µÇ¸é(ÀÚ), routine .Xr getchar 3 ¿ëÀ¸·Î ÁöÁ¤µÈ ¿¡·¯°¡ .Va errno (À¸)·Î ¼³Á¤µÇ´Â °æ¿ì°¡ ÀÖ½À´Ï´Ù. .Sh °ü·Ã Ç׸ñ .Xr feof 3 , .Xr ferror 3 , .Xr fgetln 3 .Sh Ç¥ÁØ .Fn fgets ÇÔ¼ö¿Í .Fn gets ÇÔ¼ö´Â, .St -isoC ¿¡ ÀûÇÕÇϰí ÀÖ½À´Ï´Ù. .Sh ¹ö±× Åë»ó, ´ÙÀ½ÀÇ ÀÔ·ÂÇàÀÌ ÀÖ´Â ÀÓÀÇÀÇ ±æÀ̺¸´Ù ªÀº ÀÏÀ» ÇÁ·ÎÅØ¼ÇÇÏ´Â °ÍÀº ºÒ°¡´ÉÇϰí, ¶Ç ÀÔ·Â ¹öÆÛ¸¦ ¿À¹öÇ÷οì Çϸé(ÀÚ) °ÅÀÇ ¹Ýµå½Ã º¸¾È À§¹ÝÀÌ µÇ±â (À§ÇØ)¶§¹®¿¡, ÇÁ·Î±×·¥¿¡¼­´Â .Fn gets (À»)¸¦ .Em Àý´ë·Î »ç¿ëÇÏÁö ¸»¾Æ ÁÖ¼¼¿ä. .Fn gets (Àº)´Â, .St -isoC ¿¡ ÀûÇÕÇϱâ À§ÇØ(¶§¹®¿¡)ÀÎ ¸¸Å­ Á¸ÀçÇϰí ÀÖ½À´Ï´Ù.