Why can't I find <conio.h> on Linux?

Possible duplicate:
How to implement getch () function for C on Linux?

I searched the Linux version of the conio.h header file, but could not find ...

I use gcc and a Geany text editor to compile my C code.

Is there any way to replace its functions? For example, getch()

thank

+42
c gcc linux
Jan 09 '12 at 17:11
source share
4 answers

conio.h is the C header file used by older MS-DOS compilers to create text-based user interfaces. Compilers oriented towards non-DOS operating systems such as Linux, Win32, and OS / 2 provided various implementations of these functions.

#include <curses.h> will provide you with almost all the functions that were provided in conio.h

nuclei should be installed first

In used debros distros use

sudo apt-get install libncurses5-dev libncursesw5-dev

And in rpm based distributions use

sudo yum install ncurses-devel ncurses

For the getch() function class, you can try this

+63
Jan 09 '12 at 17:21
source share

The original conio.h was implemented by Borland, so it is not part of the C standard library and is not defined by POSIX.

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

+17
Jan 09 '12 at 17:18
source share

A popular Linux library with similar functionality will be ncurses .

+4
Jan 09 2018-12-01T00:
source share

This is because it does not exist because it is limited to Windows.

Instead, use standard <stdio.h> functions, such as getc

The recommended ncurses library is good if you want to write console GUIs, but I don't think this is what you want.

+2
Jan 09 '12 at 17:19
source share



All Articles