在下面的代码中(仅用于实验目的)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()的工作方式类似,唯一的区别是后者是一个宏,是唯一的区别???
答案 0 :(得分:0)
据我所知,fgetchar()
和getchar()
之间的唯一区别是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).