gets






fgetc, fgets, getc, getchar, gets, ungetc − æåã¨æååã®å¥å


#include<stdio.h>

);int fgetc(FILE *stream
, int char *fgets(char *s
);int getc(FILE *stream
int getchar(void);
);char *gets(char *s
, FILE *int ungetc(int c

fgetc() 㯠stream ãã次ã®æåã unsignedchar ã¨ãã¦èªã¿ ã«ã‐
ã£ã¹ããã¦è¿ã. ãã¡ã¤ã«ã®çµããã¨ã©ã¼ã¨ãªã£ãå ´å㯠EOF ãè¿ãã

     getc() 㯠fgetc() ã¨åæ§ã ãã stream
ã1度以ä¸è©ä¾¡ãããã¯ãã¨ãã¦å®è£ããããããããªãã

     getchar() 㯠)getc(stdin ã¨åãã§ããã

     㯠stdin ããæ¹è¡æåããã㯠(ããã㯠ã«ç½®ãæãããã)ã¾ã§ã®1è¡ã s
ã§ç¤ºããããããã¡ã«èªã¿è¾¼ãã
ãããã¡ã®ãªã¼ãã¼ã©ã³ã¯ãã§ãã¯ãããªã(ä¸ã® ãã° ãè¦ã)ã

     fgets() 㯠n (訳注: size ã®ééãã?)  ããã1æå‐
以ä¸å°ãªãæåã stream ããèªã¿è¾¼ã¿ã ã§ç¤ºããããããã¡ã«æ¸ãè¾¼ã.
èªã¿è¾¼ã¿ã¯ EOF ã¾ãã¯æ¹è¡æåãèªã¿è¾¼ãã å¾çµããã æ¹è¡æåã¯èª‐
ã¾ããã¨ãããã¡ã«æ¸ãè¾¼ã¾ããã ’\0’ æåããããã¡ã®ä¸ã®æå¾ã®æå‐
ã®å¾ã«1æåæ¸ãè¾¼ã¾ããã

     ers ungetc() ã¯å¾ã®readæä½ã§èªããããã«ã c ã ã«ãã£ã¹ããã¦
ã«æ¸ãæ»ãã

     ããã§è¿°ã¹ãé¢æ°ã®å¼åºã stdio
ã©ã¤ãã©ãªã®å¥åé¢æ°ãåãå¥åã¹ããªã¼ã ã¸äºãã«æ··ãã¦ä½¿ããã¨ãã§ããã

ã¯æåã unsignedchar ã¨ãã¦èªãã§, int ã«ãã£ã¹ããã¦è¿ãã,
ãã¡ã¤ã«ã®çµãã EOF ã¨ãã¦è¿ãã, ã¨ã©ã¼ãè¿ãã

     ã¯æåãã㨠s ãè¿ã, ãã¡ã¤ã«ã®çµããããã¯ã¨ã©ã¼ã®å ´å NULL
ãè¿ãã

     ungetc() ã¯æåãã㨠c ãè¿ã, ã¨ã©ã¼ã®å ´å㯠EOF ãè¿ãã

ANSI ‐ C, POSIX.1

y y ãã¼ã¿ãç¥ããã¨ãªãã« gets() ãä½æåèªãããåã«ç¥ãäºã¯ã§ããã
gets() ããããã¡ã®çµããè¶ãã¦æ¸ãè¾¼ã¿ç¶ããããã使ç¨ã¯å¤§å¤å±éºã§ããã
ãã®äºã¯ã³ã³ãã¥ã¼ã¿ã®ã»ãã¥ãªãã£ãç ´ãã®ã«ä½¿ããã¦ããã 代ããã«
fgets() ã使ãã

     e undefined å¥åã¹ããªã¼ã ã®ãã¡ã¤ã«ãã£ã¹ã¯ãªãã¿ã«å¯¾ã
stdio ã©ã¤ãã©ãªã®å¥åé¢æ°ã¨ read()
ãæ··ãã¦å¼ã³åºãäºã¯å§ããããªããçµæã¯ä¸å®ã§ãããããããªãã®









                             ‐2‐


æãã§ããçµæã§ã¯ãªãã ããã