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

CLinuxGccHeader Files

C Problem Overview


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

What is the equivalent Linux version of the conio.h header file from MS-DOS?

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

> I'm using gcc and the text editor Geany to compile C code.

C Solutions


Solution 1 - C

conio.h is a C header file used with old MS-DOS compilers to create text user interfaces. Compilers that target other operating systems, such as Linux-based, 32-bit Windows and OS/2, provide equivalent functionality through other header files and libraries.

The #include <curses.h> will give you almost all of the functionality provided by conio.h.

"ncurses" needs to be installed in the first place.

If you use the Apt package manager:

sudo apt-get install libncurses5-dev libncursesw5-dev

If you use rpm:

sudo yum install ncurses-devel ncurses

For getch, take a look at the "NCURSES Programming HOWTO" article.

Solution 2 - C

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

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

Solution 3 - C

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

Use the standard functions from <stdio.h> instead, such as 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.

Solution 4 - C

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjanniksView Question on Stackoverflow
Solution 1 - CSangeeth SaravanarajView Answer on Stackoverflow
Solution 2 - CkarlphillipView Answer on Stackoverflow
Solution 3 - COttavio CampanaView Answer on Stackoverflow
Solution 4 - CAntoine GersantView Answer on Stackoverflow