Linux 上的 <conio.h> 头文件在哪里?为什么我找不到 <conio.h>?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8792317/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 03:59:59  来源:igfitidea点击:

Where is the <conio.h> header file on Linux? Why can't I find <conio.h>?

clinuxgccheader-files

提问by janniks

Possible Duplicate:
How to implement getch() function of C in Linux?

可能的重复:
如何在 Linux 中实现 C 的 getch() 函数?

What is the equivalent Linuxversion of the conio.hheader file from MS-DOS?

MS-DOS 头文件的等效Linux版本是conio.h什么?

Is there a way to replace its functionality? e.g. getch()

有没有办法替换它的功能?例如getch()

I'm using gccand the text editor Geanyto compile Ccode.

我正在使用gcc和文本编辑器Geany来编译C代码。

采纳答案by Sangeeth Saravanaraj

conio.his a Cheader file used in old MS-DOS compilers to create text user interfaces. Compilers that targeted non-DOS operating systems, such as Linux, Win32 and OS/2, provided different implementations of these functions.

conio.hC旧 MS-DOS 编译器中用于创建文本用户界面的头文件。针对非 DOS 操作系统(如 Linux、Win32 和 OS/2)的编译器提供了这些函数的不同实现。

The #include <curses.h>will give you almost all the functionalities that was provided in conio.h

#include <curses.h>会给你几乎所有的在所提供的功能conio.h

nucurses need to be installed at the first place

首先需要安装nucurses

In deb based Distros use

在基于 deb 的发行版中使用

sudo apt-get install libncurses5-dev libncursesw5-dev

sudo apt-get install libncurses5-dev libncursesw5-dev

And in rpm based distros use

在基于 rpm 的发行版中使用

sudo yum install ncurses-devel ncurses

sudo yum install ncurses-devel ncurses

For getch()class of functions, you can try this

对于getch()函数类,你可以试试这个

回答by Antoine Gersant

A popular Linux library which has similar functionality would be ncurses.

具有类似功能的流行 Linux 库是ncurses

回答by karlphillip

The original conio.hwas implemented by Borland, so its not a part of the C Standard Library nor is defined by POSIX.

最初的conio.h是由 Borland 实现的,所以它不是 C 标准库的一部分,也不是由 POSIX 定义的。

But here is an implementation for Linuxthat uses ncurses to do the job.

但这里有一个 Linux 实现,它使用 ncurses 来完成这项工作。

回答by Ottavio Campana

That is because is does not exist, since it is bounded to Windows.

那是因为 is 不存在,因为它绑定到 Windows。

Use the standard functions from <stdio.h>instead, such as getc

改用标准函数<stdio.h>,例如 getc

The suggested ncurses library is good if you want to write console-based GUIs, but I don't think it is what you want.

如果您想编写基于控制台的 GUI,建议的 ncurses 库很好,但我认为这不是您想要的。