How do I read numbers and be able to evaluate a specific key at any time during the execution of the program?

0

The problem I have is that I have to fill a matrix and that during the filling process if I typed the 'd' key, I could delete some number of the ones entered or if 'l' could delete them all. I've tried with kbhit () and getch () but when entering a letter it does not let me re-enter numbers. I attach a small example of what I want to do.

int main(){
    int x;
    char tecla;
    do{
        if (kbhit()) {
           tecla = getch();
        } else {
           tecla = ' ';
        }
       if(tecla!=' '){
           if(tecla=='l'){
               cout<<"ele"<<endl;
           }else if(tecla=='v'){
               cout<<"uve"<<endl;
           }else if(tecla=='d'){
               cout<<"de"<<endl;
           }else{
               cin>>x;
               cout<<x<<endl;
           }
       }
   }while(true);
   return 0;
}
    
asked by Francisco Espinoza Sánchez 05.07.2017 в 19:21
source

0 answers