先贴上几个网址,其中英文的有空在翻译,尤其是英文的价值含量高
英文的网址:
终极解惑版---http://bytes.com/topic/c/answers/222619-setbuf-stdin-null-cant-work-why
scanf的标准解释:http://www.cplusplus.com/reference/clibrary/cstdio/scanf/
setbuf的标准解释:http://www.cplusplus.com/reference/clibrary/cstdio/setbuf/
getchar的标准解释:http://www.cplusplus.com/reference/clibrary/cstdio/getchar/
fflush的标准解释:http://www.cplusplus.com/reference/clibrary/cstdio/fflush/
scanf函数和输入缓存的关系,scanf函数输入格式的问题:
http://www.c-faq.com/stdio/scanfhang.html
http://www.c-faq.com/stdio/scanfinterlace.html
http://www.c-faq.com/stdio/scanfjam.html
http://www.c-faq.com/stdio/scanfprobs.html
调用fflush、getchar等清空输入缓存的问题:
http://www.c-faq.com/stdio/stdinflush2.html
fflush vs gets:http://www.c-faq.com/stdio/gets_flush1.html
Flushing pending input so that a user's typeahead isn't read at the next prompt:http://www.mega-nerd.com/erikd/BOOK/list1306.html
中文的网址:
关于流和缓冲区的理解以及一般标准输入问题的解决方法小结:http://bbs.chinaunix.net/viewthread.php?tid=588099&from=favorites(里面有一些错误,请注意)
对上一网址内容的不解,引发出来的问题:http://bbs.chinaunix.net/viewthread.php?tid=592715&extra=&page=1(最终感觉还是没有解释明白)
基本上全部看完之后,不得不说,外国人的编程水平确实要高一个档次。
尤其注意的是fflush(stdin)不是标准,而是未定义行为,fflush()不是丢弃,而且刷新--将其流写到与之关联的文件中。c语言中没有明确清除输入缓存的函数。