El problema es que necesito que al estar en el menú pueda salir del programa con la tecla "esc" en vez de el número 3 , y también para regresar al menú después de entrar a una opción debe ser con la letra "s" , también tengo duda si la forma en la que hice el menú es la correcta , me corre bien el programa eso me hace suponer q tal vez no voy tan mal :s jeje , bueno espero que me puedan ayudar , quiero aprender a programar de forma correcta les agradecería mucho su ayuda
Código
#include <iostream> #include <conio.h> using namespace std; struct alumnos { char nom[50],semestre[50],grupo[50]; float califi; } alumn [3]; int main() { int x,z; int opcion; float prom,T=0,*pprom; pprom=&prom; do{ system ("cls"); cout << "\n\t\t\t MENU DE OPCIONES \n\n"; cout << "\t 1.-CAPTURAR DADTOS DEL ALUMNO \n"; cout << "\t 2.-INFORMACION DEL ALUMNO Y PROMEDIO GRUPAL \n"; cout << "\t 3.-SALIR \n\n"; cout << "\t ELIJA UNA OPCION:"; cin >> opcion; switch (opcion) { case 1: for(x=0;x<3;x++) { fflush(stdin); system("cls"); cout<< "\t\t INGRESA LOS SIGUIENTES DATOS DEL ALUMNO\n\n\n"; cout<< "NOMBRE: "; cin.getline(alumn[x].nom, 50); cout<< "SEMESTRE: "; cin.getline(alumn[x].semestre, 50); cout<< "GRUPO: "; cin.getline(alumn[x].grupo, 50); cout<< "CALIFICACION: "; cin >> alumn[x].califi; if (x==2) { cout << "PRESIONA CUALQUIER TECLA PARA REGRESAR AL MENU"; getch(); } } system("cls"); break; case 2: system ("cls"); for (z=0;z<3;z++) { cout << "\n\tALUMNO" << " " << (z+1) << "\n\n"; cout << "\tNOMBRE:" <<alumn[z].nom <<endl << "\tSEMESTRE:"<<alumn[z].semestre <<endl << "\tGRUPO:"<<alumn[z].grupo <<endl << "\tCALIFICACION:"<<alumn[z].califi<<"\n\n" ; T=T+alumn[z].califi; prom=T/3; if(z==2) { cout << "\n\t\t PROMEDIO GRUPAL: " << *pprom <<"\n\n\n"; T=0; cout << "\t\tPRESIONA CUALQUIER TECLA PARA REGRESAR AL MENU"; } } getch(); system("cls"); break; case 3: system("cls"); return 0; default: system ("cls"); cout << "\t\t\t ERROR!!!!!"<<endl <<"OPCION NO VALIDA PRESIONA UNA TECLA PARA REGRESAR AL MENU"; getch(); break; } } while (opcion=3); }