在下面的代码中(仅出于实验目的),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()类似,唯一的区别是后者是宏,这是唯一的区别吗???
最佳答案
据我所知,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).
关于c - fgetchar()的功能是什么?使用前是否需要冲洗标准输入?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33438701/