creacion del archivo getch con la funcion getch
This commit is contained in:
@@ -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;
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,24 +1,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <termios.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
using namespace std;
|
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(){
|
void clear(){
|
||||||
ifstream archivo("/etc/os-release");
|
ifstream archivo("/etc/os-release");
|
||||||
|
|
||||||
@@ -27,12 +11,12 @@ void clear(){
|
|||||||
} else {
|
} else {
|
||||||
system("cls");
|
system("cls");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
|
||||||
char opcion=0;
|
char opcion=0;
|
||||||
while (opcion!='8')
|
while (opcion!='8')
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user