As per the standard,fflushis limited to output buffers. Therefore,stdincannot be utilized as it does not qualify as an output buffer. Nevertheless, a few standard C libraries offerfflush(stdin)as an extension, which can be used in such cases. However, it will impact the portability of the ...
discarding unread input would not be an analogous meaning for fflush on input streams. There is no standard way to discard unread characters from a stdio input buffer, nor would such a way be sufficient; unread characters
(2)读入字符时清除缓冲区可以采用while循环将缓冲区里的字符都读出,可以把它写成宏或者内联函数 /*method 1: macro definition of read a character from the stdin and then flush the buffer*/ #define scanf_flush(ch)\ {int c;\ if(scanf("%c", ch)!=EOF){while((c=getchar())!='\n'&&c!=...