linux下kbhit()函数 getch函数。
linux下kbhit()函数 getch函数。 怎样在C语言执行循环程序时按键盘任意键停止程序,再按再继续执行? 参考http://zhidao.baidu.com/question/272086855.html 在linux下C语言写了一个while循环,怎么实现按任意键退出。如何编写程序? 参考:http://zhidao.baidu.com/question/461121586.html 对于上面的问题,都用到 linux下的getch函数与kbhit函数。 参考了http://kpld8888.wordpress.com/2007/03/07/linux%E4%B8%8B%E7%9A%84getch%E5%87%BD%E6%95%B0%E4%B8%8Ekbhit%E5%87%BD%E6%95%B0-2/ 和:http://zhidao.baidu.com/question/461121586.html 但是我照搬上面两条都不能很好的编译,总是有错误。奉上我的文件: 将下列三个文件放在工程目录下,build project即可。 main.c: 1. #include "kbhit.h" 2. #include <stdio.h> 3. #include <stdlib.h> 4. #include "accelerometer.h" //contains the middle level macros, state variable 5. // definition and declaration for the 6. //middle layer (class layer) functions 7. 8. 9. 10. void delay(int a){ 11. int i,j,delay; 12. for(i = 0 ; i < 1170*(200/a); i++){ 13. delay = 0; 14. for(j = 0; j < 100; j++){ 15. delay = delay+1; 16.
…