0

在以下代码中(仅用于实验目的) fgetchar() 获取系统缓冲区中存在的值并因此被终止,为什么?

#include<stdio.h>
#include<conio.h>
int main()
{
printf("Here getch will take the value and it will not echo and will take without enter\n");
getch();
printf("Here getchar will take the value but it will echo on entering ");
getchar();
printf("Here getche will take the value but it will echo not on entering\n");
getche();/*fflush(stdin);*/
printf("now we are going to illustrate the usage of macros");
fgetchar();
}

我读过 fgetchar() 的工作方式类似于 getchar() 唯一的区别是后者是一个宏,这是唯一的区别吗???

4

1 回答 1

0

fgetchar()据我所知,和getchar()is之间的唯一区别fgetchar()是调用系统函数的宏fgetc()

以下是手册页所说的:

   fgetc() reads the next character from  stream  and  returns  it  as  an
   unsigned char cast to an int, or EOF on end of file or error.

   getc()  is equivalent to fgetc() except that it may be implemented as a
   macro which evaluates stream more than once.

   getchar() is equivalent to getc(stdin).
于 2015-10-30T16:01:34.060 回答