C语言编程—清空键盘缓冲区,Linux和Windows下完美实现(转)
摘要:
清空键盘缓冲区很多种方法,如用fflush(stdin);rewind(stdin);等,但是在linux这些都不起作用,还得我今天试了半天都没成功,上网搜了一下发现setbuf(stdin, NULL);就能直接清空键盘缓冲区了。以下几个实例:Sample one123456789101112#include <stdio.h>intmain(){ charch1; charch2; ch1=getchar(); ch2=getchar(); printf("%d %d",ch1,ch2); return0;}程序的本意很简单,就是从键盘读入两个字符,然后打印 阅读全文
posted @ 2013-06-08 17:26 净坛使者 阅读(400) 评论(0) 推荐(0)
浙公网安备 33010602011771号