funciones getch y clear
This commit is contained in:
@@ -1,16 +1,44 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <conio>
|
||||
#include <termios.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
using namespace std;
|
||||
|
||||
char getch(void){
|
||||
struct termios oldt, newt;
|
||||
char ch;
|
||||
|
||||
tcgetattr(STDIN_FILENO, &oldt);
|
||||
newt = oldt;
|
||||
newt.c_lflag &= ~(ICANON | ECHO);
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &newt);
|
||||
ch = getchar();
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
void clear(){
|
||||
ifstream archivo("/etc/os-release");
|
||||
|
||||
if (archivo.good()) {
|
||||
system("clear");
|
||||
} else {
|
||||
system("cls");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
char opcion;
|
||||
while (opcion!=8)
|
||||
char opcion=0;
|
||||
while (opcion!='8')
|
||||
{
|
||||
cout<<opcion<<enl<<endl;
|
||||
cout<<"SANCIONES APP. MENU PRINCIPAL"<<endl;
|
||||
cout<<"===================================="<<endl;
|
||||
cout<<"Indroduce un numero entre 1 y 8"<<endl;
|
||||
cout<<" 1. Consultar cehiculo."<<endl;
|
||||
cout<<" 2. Añadir vehiculo."<<endl;
|
||||
cout<<" 3. Mostrar radares."<<endl;
|
||||
@@ -19,8 +47,11 @@ int main()
|
||||
cout<<" 6. Mostrar fichero de sanciones."<<endl;
|
||||
cout<<" 7. Mostrar cuantia de sancion."<<endl;
|
||||
cout<<" 8. Salir."<<endl;
|
||||
cout<<"Introduce un opcion";
|
||||
opcion=getch();
|
||||
};
|
||||
system("clear");
|
||||
cout<<opcion;
|
||||
clear();
|
||||
};
|
||||
clear();
|
||||
return 0;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user