Paste the contents of the dashed box into the text of the document
----------------------------------------------------------------------------------------------------------
#include <termios.h>
#include <stdio.h>
static struct Termios old, new;
/* Initialize new terminal I/O settings */
void Inittermios (int echo)
{
Tcgetattr (0, &old); /* Grab old terminal I/O settings */
new = old; /* Make new settings same as old settings */
New.c_lflag &= ~icanon; /* Disable buffered I/O */
New.c_lflag &= Echo? ECHO: ~echo; /* Set echo Mode */
Tcsetattr (0, Tcsanow, &new); /* Use these new terminal I/O settings now */
}
/* Restore old terminal I/O settings */
void Resettermios (void)
{
Tcsetattr (0, Tcsanow, &old);
}
/* Read 1 Character-echo defines echo mode */
char getch_ (int echo)
{
Char ch;
Inittermios (Echo);
ch = getchar ();
Resettermios ();
return ch;
}
/* Read 1 character without echo */
Char getch (void)
{
Return Getch_ (0);
}
/* Read 1 character with Echo */
Char getche (void)
{
return Getch_ (1);
}
/* Let's Test it out */
----------------------------------------------------------------------------------------------------
Save As to/usr/include/conio.h
Ubuntu uses conio.h under Windows