need help (loop with switch)

hey !
(sorry my english is not good enough)
i need ur help in my project.it's about airplane reservation system. so i did all the functions right but i have a problem with loop around switch . is it possible ?
i want a loop so the program doesn't exit after each case this is a sample of my code and output
1
2
3
cout<<"\n1. Show number of empty seats\n2. Show empty seats' position\n3. Reserve a seat\n4.Cancel a seat\n5.Exit the program\n";
cin>>choice;
switch(choice)

i want the output to be like this
1- Show number of empty seats 2-Show empty seats' position 3-Reserve a seat 4- Cancel a seat
1
the number of empty seats is 15
1- Show number of empty seats 2-Show empty seats' position 3-Reserve a seat 4- Cancel a seat


hope you understand what i want !
thank you
Last edited on
That's simple:

1
2
3
4
5
6
7
8
9
10
11
12
13
void f()
{
    while(true)
   {
          cin >> choice;

          switch(choice)
          {
            default:
            return;
          }
    }
}
Last edited on
thank u so much . it worked !

but with the last case(Exit the program) it doesn't .
is there any function to exit the program ?
is there any function to exit the program ?


Yes,
The funciton has the following signature:
1
2
3
4
int main()
{
     return 0;
}


But If you want to exit a program from within another function use exit(iParam); where iParam is integral value returned to the OS

don't forget to include <cstdlib> to be able to use that luxury :D
also don't forget to release your pointers before calling exit()

Hope this helps.
thanx Alot !
Topic archived. No new replies allowed.