› Foros › PC › Software libre
#include<iostream>
#include<cstdlib>
using namespace std;
unsigned int Menu();
unsigned int MenuName();
int main(){
unsigned int opc,opcion;
string name;
do{
opcion=Menu();
switch(opcion){
case 1:
cout<<"Your name:";
cin>>name;
cin.get();
break;
case 2:
cout<<"Hello"<<endl;
cin.get();
break;
case 3:
cout<<"Hello"<<endl;
cin.get();
break;
case 4:
cout<<"bye"<<endl;
cin.get();
break;
}
}while(opcion!=4);
}
unsigned int Menu(){
unsigned int opt;
system("clear");
cout<<"**************************************************************************\n"<<endl;
cout<<"\t1 - Name"<<endl;
cout<<"\t2 - Address"<<endl;
cout<<"\t3 - Surname"<<endl;
cout<<"\t4 - Exit"<<endl;
cout<<"\n\n**************************************************************************\n"<<endl;
cout<<"\t\tSelect option: ";
cin>>opt;
cin.get();
return opt;
}
#include<iostream>
#include<cstdlib>
#include<limits> // <--------------------------
using namespace std;
unsigned int Menu();
unsigned int MenuName();
int main(){
unsigned int opc,opcion;
string name;
do{
opcion=Menu();
switch(opcion){
case 1:
cout<<"Your name:";
cin>>name;
break;
case 2:
cout<<"Hello"<<endl;
cin.get();
break;
case 3:
cout<<"Hello"<<endl;
cin.get();
break;
case 4:
cout<<"bye"<<endl;
cin.get();
break;
}
}while(opcion!=4);
}
unsigned int Menu(){
unsigned int opt;
system("clear");
cout<<"**************************************************************************\n"<<endl;
cout<<"\t1 - Name"<<endl;
cout<<"\t2 - Address"<<endl;
cout<<"\t3 - Surname"<<endl;
cout<<"\t4 - Exit"<<endl;
cout<<"\n\n**************************************************************************\n"<<endl;
cout<<"\t\tSelect option: ";
cin>>opt;
cin.ignore(numeric_limits<streamsize>::max(), '\n'); //<---------------------
cin.get();
return opt;
}