diff --git a/Practica1/getch.cpp b/Practica1/getch.cpp index e69de29..6f1de0d 100644 --- a/Practica1/getch.cpp +++ b/Practica1/getch.cpp @@ -0,0 +1,19 @@ +#include +#include +#include + +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; +}; diff --git a/Practica1/main.cpp b/Practica1/main.cpp index c8c5a02..d6ac50f 100644 --- a/Practica1/main.cpp +++ b/Practica1/main.cpp @@ -1,38 +1,22 @@ #include #include -#include -#include -#include + 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"); + ifstream archivo("/etc/os-release"); if (archivo.good()) { system("clear"); } else { system("cls"); } - }; +}; int main() -{ + char opcion=0; while (opcion!='8') {