#include <stdio.h>
#include <unistd.h>
#include <termios.h>
#include <string.h>
main () {
char *m,*b,*w,*l,*d,*a,*p;
int option;
struct termios oldt, newt;
/* tcgetattr gets the parameters of the current terminal
* STDIN_FILENO will tell tcgetattr that it should write the settings
* of stdin to oldt
*/
tcgetattr( STDIN_FILENO, &oldt);
/*now the settings will be copied*/
memcpy((void *)&newt, (void *)&oldt, sizeof(struct termios));
newt.c_lflag &= ~(ICANON); // Reset ICANON so enter after char is not needed
newt.c_lflag &= ~(ECHO); // Turn echo off
/*
* Those new settings will be set to STDIN
* TCSANOW tells tcsetattr to change attributes immediately.
*/
tcsetattr( STDIN_FILENO, TCSANOW, &newt);
m="\t\t Main Menu \t\t";
b="------------------------";
w="1- Word Perfect.";
l="2- Lotus 1-2-3.";
d="3- dBase IV.";
a="4- AutoCAD.";
p="Press the required number:";
printf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s ",m,b,w,l,d,a,b,p);
option=getchar(); //this is where the getch is used
printf("\nYour choice is: %c\n",option);
/*
* Restore original settings
*/
tcsetattr( STDIN_FILENO, TCSANOW, &oldt);
}
~