Problems with a do while loop

I have a do while loop that has if statements in it. The problem is that once it is done executing one part of the if statement, it automatically moves to the next part of the if statement. What I need it to do is start over at the beginning of the do while loop. Please help!!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
void menu()
{
     expense all_expenses[100];
     int num_expenses=0;
     char choice;
     do
     {
          cout<<"Enter 'a' to enter new expenses, 'd' to display expenses,"<<endl;
          cout<<" enter 'f' to find an expense or 'q' to quit"<<endl;
          cin>>choice;
          cin.ignore(100,'\n');
          if ('a'==choice)
             add(all_expenses, num_expenses);
          else if ('d'==choice)
             display(all_expenses, num_expenses);
          else ('f'==choice);
             find(all_expenses,num_expenses);
     }while(choice!='q');
}     
lovely6922 wrote:
once it is done executing one part of the if statement, it automatically moves to the next part of the if statement


What exactly do you mean by this...?
Say the user enters an 'a' for the add function, once that function completes it moves to the display function. I need the program to allow the user to choose what to do next. i.e I need the loop to start again on line 8.
You have an extra ';' after your else which might be causing that issue (the find function always runs).
Yeah I didn't think that ; should be there either but without it I get an error code. "Expected ; before find"
Last edited on
I solved it for some reason it didn't like my else statement. It wanted it to be an else if. Thanks for the help.
Topic archived. No new replies allowed.