creacion del archivo getch con la funcion getch

This commit is contained in:
Pablo
2026-03-18 12:42:29 +01:00
parent 47e11842a8
commit d986ff0879
2 changed files with 23 additions and 20 deletions

View File

@@ -0,0 +1,19 @@
#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;
};

View File

@@ -1,24 +1,8 @@
#include <iostream>
#include <fstream>
#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");
@@ -27,12 +11,12 @@ void clear(){
} else {
system("cls");
}
};
};
int main()
{
char opcion=0;
while (opcion!='8')
{