i wrote up a code from one of my c++ books and its all good and well but i would like it instead of jus doing a simple cout " o hai!" i want it to do sumthin though this code was wrote mostly in a forever loop and switch case typa style ..my main question is it possible to make a switch case style actually do sumthin other then jus take an input ..can i make a case(5):
DoShutDown;
break;
heres the original code, and i have the shutdown code jus not sure if it would work in the original code and or in the switch case style. thanks, kc
CODE
#include <iostream>
int menu();
void DoTaskOne();
void DoTaskMany(int);
using namespace std;
int main()
{
bool exit= false;
for(;;)
{
int choice = menu();
switch(choice)
{
case(1):
DoTaskOne();
break;
case(2):
DoTaskMany(2);
break;
case(3):
DoTaskMany(3);
break;
case(4):
continue;
break;
case(5):
exit = true;
break;
default:
cout<<"Please select again!"<<endl;
break;
}
if (exit==true)
break;
}
return 0;
}
int menu ()
{
int choice;
cout<<"**** Menu ****"<<endl<<endl;
cout<<"(1) Choice one."<<endl;
cout<<"(2) Choice two."<<endl;
cout<<"(3) Choice three."<<endl;
cout<<"(4) Redisplay Menu."<<endl;
cout<<"(5) Quit."<<endl<<endl;
cout<<":";
cin>>choice;
return choice;
}
void DoTaskOne ()
{
cout<<"Task One!"<<endl;
}
void DoTaskMany(int which)
{
if (which==2)
cout<<"Task Two!"<<endl;
else
cout<<"Task Three!"<<endl;
}
This post has been edited by NickDMax: 3 Aug, 2008 - 10:26 PM