gets

å称
     fgets, gets — ã¹ããªã¼ã ããè¡ãåå¾

ã©ã¤ãã©ãª
     Standard C Library (libc, -lc)

æ¸å¼
     <stdio.h> char * fgets(char *str, int size, FILE *stream) char *
     gets(char *str)

解説
     fgets() é¢æ°ã¯ãæ大㧠size ã§æå®ãããæåæ°ãã 1 ã ãå°ãªãæ°ã®æåã stream ããèª‐
     ã¿è¾¼ã¿ãæåå str ã«ä¿åãã¾ãã èªè¾¼ã¿ã¯ãæ¹è¡æåãè¦ã¤ãã£ããããã¡ã¤ã«ã®çµäº
     ãããã¯ã¨ã©ã¼ãè¦ã¤ãã£ããããå ´åã«åæ¢ãã¾ãã æ¹è¡æåã¯ãåå¨ãã¦ããã°ä¿æããã¾ãã
     ä»»æã®æåãèªã¿è¾¼ãã§ã¨ã©ã¼ãçºçããªãã£ãå ´åã æååã®æå¾ã«ã¯ ‘\0’ æå‐
     ã追å ããã¾ãã

     gets() é¢æ°ã¯ fgets() é¢æ°ã§ size ãç¡éã«ãã stdin ã stream ã«ãããã®ã¨ç‐
     価ã§ããã æååä¸ã§æ¹è¡æåãä¿åãããªã (æ¹è¡æåãåå¨ããå ´å) ç¹ã ç°ãªãã¾ãã å¥åè¡ãå‐
     å¨ããå ´åããããååçãæååã«åã¾ããã ãã¨ãä¿è¨¼ããã®ã¯å¼ã³åºãå´ã®è²¬ä»»ã§ãã

æ»ãå¤
     æ£å¸¸çµäºããã¨ã fgets() 㨠gets() ã¯æååã®ãã¤ã³ã¿ãæ»ãã¾ãã ãã£ã©ã¯ã¿ãèª‐
     ã¿è¾¼ãåã«ãã¡ã¤ã«ã®çµäºã«éããã¨ã NULL ãæ»ããã¾ãã
     ãã®å ´åããããã¡ã®å容ã¯å¤åãã¾ãããã¨ã©ã¼ãçºçãã㨠NULL
     ãæ»ããããããã¡ã®å容ã¯ä¸å®ã«ãªãã¾ãã fgets() é¢æ°ã¨ gets()
     é¢æ°ã¯ãã¡ã¤ã«ã®çµäºã¨ã¨ã©ã¼ã¨ãåºå¥ãã¾ããã ãã¡ã¤ã«ã®çµäºãã¨ã©ã¼ããå¤æ‐
     ããã«ã¯ãå¼ã³åºãå´ã feof(3) 㨠ferror(3) ã使ç¨ããªãã¦ã¯ãªãã¾ããã

ã¨ã©ã¼
     [EBADF]            æå®ããã stream ããèªè¾¼ã¿å¯è½ãªã¹ããªã¼ã ã§ã¯ããã¾ããã

     fgets() é¢æ°ãã¨ã©ã¼ã«ãªãã¨ãã«ã¼ãã³ fflush(3), fstat(2), read(2),
     malloc(3) ç¨ã«æå®ãããã¨ã©ã¼ã®ããããã errno ã«è¨å®ãããå ´åãããã¾ãã

     gets() é¢æ°ãã¨ã©ã¼ã«ãªãã¨ãã«ã¼ãã³ getchar(3) ç¨ã«æå®ãããã¨ã©ã¼ã errno
     ã«è¨å®ãããå ´åãããã¾ãã

é¢é£é ç®
     feof(3), ferror(3), fgetln(3)

è¦æ ¼
     fgets() é¢æ°ã¨ gets() é¢æ°ã¯ã ISO/IEC 9899:1990 (“ISO C90”) ã«é©åãã¦ãã¾ãã

ãã°
     é常ã次ã®å¥åè¡ãããä»»æã®é·ãããçããã¨ãä¿è¨¼ããã®ã¯
     ä¸å¯è½ã§ãããã¾ãå¥åãããã¡ããªã¼ãããã¼ãã㨠ã»ã¼å¿ãã»ãã¥ãªãã£éåã¨ãªãããã ãã‐
     ã°ã©ã ã§ã¯ gets() ã 絶対㫠使ç¨ããªãã§ãã ããã gets() ã¯ã ISO/IEC
     9899:1990 (“ISO C90”) ã«é©åããããã ãã«åå¨ãã¦ãã¾ãã