无法让 _kbhit 在 Windows 上继续工作,conio 问题
编译 Microsoft 的使用 _kbhit 的 C 示例程序向我显示了此错误:
fatal error: conio.h: No such file or directory
我使用 Code::Blocks 和 GNU GCC 编译器以及 Windows 10
。奇怪的是,这段代码在两个月前就有效了。
为什么 conio 会抛出错误?我还需要添加其他内容吗?这不是标准的C库吗?
Compiling Microsoft's sample program in C for using _kbhit thows me this error:
fatal error: conio.h: No such file or directory
I use Code::Blocks and GNU GCC compiler, and Windows 10.
The weird thing about that is, that this code worked 2 months ago.
I remember I was advised to use conio and _kbhit from here and here
Why does conio throws me an error? Do I need to include something else? Isnt it standar C library?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
哪个 GNU GCC 编译器? CYGWIN 还是 MinGW? Cygwin 没有“conio.h”,而 MinGW 有。所以可能是你过去使用MinGW并且一切正常,然后迁移到Cygwin(我自己也有这样的迁移)。
一般来说,原生 Linux GCC 不支持“conio.h”,因为 GCC 是基于 Linux 的编译器,而“conio.h”是古老的 DOS 库。为了能够使用“conio.h”,请确保使用 MinGW GCC 或基于 Windows 的编译器(例如,“conio.h”仍然存在的 Embarcadero C++ Builder 或 Visual Studio C/C++)来编译代码。
另外,使用 GCC 中存在的 NCurses 库可能是一个好主意,它提供与 conio.h 类似的功能(甚至更好);尽管没有 kbhit() 函数 - 您需要自己实现它(例如 http:// www.flipcode.com/archives/_kbhit_for_Linux.shtml)
Which GNU GCC compiler? Cygwin or MinGW? Cygwin doesn't have 'conio.h' while MinGW got it. So it might be that you used in the past MinGW and everything worked, and then moved to Cygwin (I myself also had such migration).
In general native Linux GCC doesn't support 'conio.h' because GCC is Linux-bases compiler, while 'conio.h' is ancient DOS library. To be able to use 'conio.h' be sure to compile the code with MinGW GCC or Windows-based compilers (eg Embarcadero C++ Builder or Visual Studio C/C++ where 'conio.h' still exists).
Also it might be a good idea to use NCurses library instead which exists in GCC and provide similar functions as conio.h (and even better); though there is no kbhit() function - you need to to implement it yourself (eg http://www.flipcode.com/archives/_kbhit_for_Linux.shtml )