From 31a90187a62a40c1b51fe65fbb386b068773503e Mon Sep 17 00:00:00 2001 From: karto Date: Sat, 14 Mar 2026 17:25:51 +0100 Subject: [PATCH] funciones getch y clear --- Practica1/main.cpp | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/Practica1/main.cpp b/Practica1/main.cpp index 212a66f..c8c5a02 100644 --- a/Practica1/main.cpp +++ b/Practica1/main.cpp @@ -1,16 +1,44 @@ #include #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"); + + if (archivo.good()) { + system("clear"); + } else { + system("cls"); + } + }; + + + int main() { - char opcion; - while (opcion!=8) - { - cout<