http://www.360doc.com/content/12/0414/09/1317564_203474440.shtml
kbhit in c: kbhit function is used to determine if a key has been pressed or not. To use kbhit function in your program you should include the header file "conio.h". If a key has been pressed then it returns a
non zero value otherwise returns zero.
Declaration : int kbhit();
C programming code for kbhit
#include <stdio.h>
#include <conio.h>
main()
{
while (!kbhit())
printf("You haven't pressed a key.\n");
return 0;
}
As long as in the above program user doesn't presses a key kbhit() return zero and (!0) i.e. 1 the condition in while loop is true and "You haven't pressed a key." will be printed again and again. As a key is pressed
from the keyboard the condition in while loop become false as now kbhit() will return a non-zero value and ( !(non-zero) = 0), so the control will come out of the while loop.
===========================
ubuntu上没有conio.h如何解决
www.MyException.Cn 发布于:2012-08-01 17:53:40 浏览:142次
本人用的ubuntu12.04版本,gcc是4.6.3版本,要下载什么样的conio.h和库文件?难道只能用ncurses替代吗
------解决方案--------------------------------------------------------
来自百度百科:
conio 库不仅适用于 Window 平台,在 Linux 下也可使用.网上已经有兼容包,下载后打开就可使用;而至于Mac则完全跟Window没有区别,直接可以使用.
------解决方案--------------------------------------------------------
自己没试过,希望对你有帮助,或者直接自己搜索关键字 "linux 使用 conio.h".
http://zhidao.baidu.com/question/241772898.html
http://tech.techweb.com.cn/thread-183749-1-1.html
------解决方案--------------------------------------------------------
用curses.h
------解决方案--------------------------------------------------------
sudo apt-get install libncurses5-dev
|
请发表评论