conio.his notCheader files in the standard library,ISOand thePOSIXare not defined in the standard.
Coniois aConsole input/output(console input and output), which defines the functions of data input and data output through the console. It is mainly the corresponding actions that some users produce by pressing the keyboard. For examplegetch ()functions, and so on. MostDOS. Windows,Phar Lap,Dosx,OS/2and other platforms on theCThe compiler provides this file,UNIXand theLinuxPlatform forCThe compiler itself usually does not include this header file, but already has its Compatibility pack, which can be included:
http://conio.sourceforge.net/
In addition, we usually use the mainconio.hin this header file.getch ()function, which reads the keyboard character but does not display it (without Echo), but containsconio.hthe program inLinuxcannot be compiled directly through, becauseLinuxThere is no such header file. In addition to using the above Compatibility Pack, you can alsoLinuxUsing native methods to achieve the same effect is to useLinuxcommand of the systemStty–echo. It does not show the input content, the source code for example.
In Windows
#include <stdio.h>
#include <conio.h>
int main () {
char c;
printf ("Input a char:");
C=getch ();
printf ("You have inputed:%c \ n", c);
return 0;
}
In Linux
#include <stdio.h>
int main () {
char c;
printf ("Input a char:");
System ("Stty-echo");
C=getchar ();
System ("Stty echo");
printf ("You have inputed:%c \ n", c);
return 0;
}
Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.
Linux does not have a way of conio.h solution