SETBUF
Section: ¸®´ª½º ÇÁ·Î±×·¡¸Ó ¸Å´º¾ó (3)
Updated: 1993³â 11¿ù 29ÀÏ
Index
Return to Main Contents
À̸§
setbuf, setbuffer, setlinebuf, setvbuf - ½ºÆ®¸² ¹öÆÛ¸µ ÀÛµ¿µé
»ç¿ë¹ý
#include <stdio.h>
void setbuf(FILE *stream, char *buf);
void setbuffer(FILE *stream, char *buf, size_tsize);
void setlinebuf(FILE *stream);
int setvbuf(FILE *stream, char *buf, int mode
, size_t size);
¼³¸í
ÀÌ¿ëÇÒ¼ö ÀÖ´Â ¹ö¸®ÇÎÀÇ 3°¡Áö ŸÀÔÀº ºñ ¹öÆÛ¸µ, ºí·° ¹öÆÛ¸µ ±×¸®°í ¶óÀÎ
¹öÆÛ¸µÀÌ´Ù.
Ãâ·Â ½ºÆ®¸²ÀÌ ºñ ¹öÆÛ¸µÀ϶§, Á¤º¸´Â ¾²ÀÚ¸¶ÀÚ ¸ñÀû ÆÄÀÏÀ̳ª Å͹̳ο¡ ³ªÅ¸³´Ù.;
ºí·° ¹öÆÛ¸µÀ϶§ ¸¹Àº ¹®ÀÚµéÀº ºí·°À¸·Î½á ÀúÀåµÇ°í ¾²¿©Áø´Ù;
¶óÀÎ ¹öÆÛ¸µÀ϶§ ¹®ÀÚµéÀº ´º¶óÀÎÀÌ Ãâ·ÂµÉ¶§±îÁö³ª Å͹̳ΠÀåÄ¡(stdin)¿¡ ºÎÂøµÈ ½ºÆ®¸²¿¡¼ ÀÔ·ÂÀÌ ÀÐÇôÁú¶§±îÁö ÀúÀåµÈ´Ù.
ÇÔ¼ö
fflush(3)´Â
ºí·°À» Áö¿ìµµ·Ï °¿äÇÒ¶§ ¾²¿©Áø´Ù.(
fclose(3)¸¦
ÂüÁ¶Çضó.)
º¸Åë ¸ðµç ÆÄÀϵéÀº ºí·° ¹öÆÛ¸µÀÌ´Ù. óÀ½ I/O ÀÛµ¿µéÀÌ ÆÄÀÏ¿¡¼ ÀϾ¶§,
malloc(3)ÀÌ
ºÒ·ÁÁø´Ù. ±×¸®°í ¹öÆÛ¸¦ ¾ò´Â´Ù.
¸¸ÀÏ ½ºÆ®¸²ÀÌ Å͹̳ο¡ ¿¬°èµÇ¾î ÀÖ´Ù¸é(º¸Åë
stdout
ó·³), ½ºÆ®¸²Àº ¶óÀÎ ¹öÆÛ¸µÀÌ´Ù. Ç¥ÁØ ¿¡·¯ ½ºÆ®¸²
stderr
´Â Ç×»ó ±âº»ÀûÀ¸·Î ºñ ¹öÆÛ¸µÀÌ´Ù.
setvbuf
ÇÔ¼ö´Â ¹öÆÛ¸µÀ» ¹Ù²Ù±â À§ÇØ ¾î¶²¶§µçÁö ¿·ÁÁø ½ºÆ®¸²¿¡ »ç¿ëµÉ¼ö ÀÖ´Ù.
mode
ÀÎÀÚ´Â ´ÙÀ½ ¼¼ ¸ÅÅ©·ÎÁß ÇϳªÀ̾î¾ß ÇÑ´Ù:
-
- _IONBF
-
ºñ ¹öÆÛ¸µ
- _IOLBF
-
¶óÀÎ ¹öÆÛ¸µ
- _IOFBF
-
¿ÏÀüÈ÷ ¹öÆÛ¸µ
ºñ-¹öÆÛ¸µ ÆÄÀϵéÀ» Á¦¿ÜÇÏ°í,
buf
ÀÎÀÚ´Â Àû¾îµµ
size
¹ÙÀÌÆ® ¸¸Å ±ä ¹öÆÛ¸¦ °¡¸®ÄÑ¾ß ÇÑ´Ù.; ÀÌ ¹öÆÛ´Â ÇöÀç ¹öÆÛ ´ë½Å »ç¿ëµÈ´Ù.
¸¸ÀÏ ÀÎÀÚ
buf
°¡
NULLÀ̶ó¸é,
´ÜÁö ¸ðµå¸¸ÀÌ ¿µÇâÀ» ¹Þ´Â´Ù; »õ·Î¿î ¹öÆÛ´Â ´ÙÀ½ ÀÐ°í ¾²±â ÀÛµ¿½Ã ÇÒ´çµÈ´Ù.
setvbuf
ÇÔ¼ö´Â ¾î¶²¶§µçÁö »ç¿ë°¡´ÉÇÏÁö¸¸ ``active''°¡ ¾Æ´Ò¶§´Â ½ºÆ®¸²ÀÇ ¸ðµå¸¸
¹Ù²Ü¼ö ÀÖ´Ù: Áï, ¾î¶² I/O ÀüÀ̳ª
fflushÈ£Ãâ
¹Ù·Î ÈÄ¿¡.
´Ù¸¥ ¼¼ ÇÔ¼ö´Â
setvbufÈ£ÃâÀ»
À§ÇÑ º°ÄªÀÌ´Ù.
setbuf
ÇÔ¼ö´Â Á¤È®½Ã ´ÙÀ½ È£Ãâ°ú °°´Ù.
-
setvbuf(stream, buf, buf ? _IOFBF : _IONBF, BUFSIZ);
setbuffer
ÇÔ¼ö´Â
¹öÆÛÀÇ Å©±â°¡ ±âº»°ª
BUFSIZ
·Î °áÁ¤µÇ´Â°Í º¸´Ù´Â È£ÃâÀÚ±îÁö¶ó´Â °ÍÀ» Á¦¿ÜÇÏ°í´Â °°´Ù.
setlinebuf
ÇÔ¼ö´Â Á¤È®È÷ ´ÙÀ½°ú °°´Ù:
-
setvbuf(stream, (char *)NULL, _IOLBF, 0);
°ü·Ã Ç׸ñ
fopen(3), fclose(3), fflush(3), fread(3), malloc(3),
puts(3), printf(3)
Ç¥ÁØ
setbuf
¿Í
setvbuf
ÇÔ¼ö´Â ANSI C3.159-1989 (``ANSI C'')¿¡ µû¸¥´Ù.
¹ö±×
setbuffer
¿Í
setlinebuf
ÇÔ¼ö´Â 4.2BSD ÀÌÀü¹öÀü¿¡´Â ȣȯµÇÁö ¾Ê´Â´Ù. ±×¸®°í Linux¿¡¼´Â ÀÌ¿ëÇÒ¼ö
¾ø´Ù. 4.2BSD¿Í 4.3BSD ½Ã½ºÅÛ¿¡¼,
setbuf
´Â Ç×»ó suboptimal ¹öÆÛ »çÀÌÁ »ç¿ëÇØ¾ß Çϸç ÇÇÇØÁ®¾ß ÇÑ´Ù.
¿©·¯ºÐÀº
buf
¿Í ±×°ÍÀÌ °¡¸®Å°´Â °ø°£Àº
stream
ÀÌ ´ÝÇôÁö´Â ½Ã°£¿¡µµ, ÇÁ·Î±×·¥ Á¾·á½Ã¿¡µµ ¿©ÀüÈ÷ Á¸ÀçÇÏ´Â °÷ÀÓÀ» È®½ÇÈ÷
ÇØ¾ß ÇÑ´Ù.
¿¹¸¦ µé¾î, ´ÙÀ½Àº ºÒ¹ýÀûÀÌ´Ù:
#include <stdio.h>
int main()
{
char buf[BUFSIZ];
setbuf(stdin, buf);
printf("Hello, world!\n");
return 0;
}
¿ªÀÚ
Á¤°ÈÆ <skyeyes@soback.kornet.net>, 2001³â 2¿ù 26ÀÏ
Index
- À̸§
-
- »ç¿ë¹ý
-
- ¼³¸í
-
- °ü·Ã Ç׸ñ
-
- Ç¥ÁØ
-
- ¹ö±×
-
- ¿ªÀÚ
-
This document was created by
man2html,
using the manual pages.
Time: 08:07:01 GMT, March 25, 2004