| | |
help getting !true bool to break out of program
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2005
Posts: 10
Reputation:
Solved Threads: 0
I was attempting to initilize bool done to false, then have this program continue to give the user the option to do more check balance functions util they pressed exit, however, my program continues to cycle repeatedly, even after option 5 (EXIT) is entered. Please, some help on how to recode so that program breaks out after this selection. Thanks. Will
•
•
Join Date: Dec 2004
Posts: 27
Reputation:
Solved Threads: 0
change do while into while... and initialize done = true instead of false. then when you press 5 (exit) change done = false to exit the loop...
int main ()
{
double checking, savings;
int choice;
get_balances (checking, savings);
bool done = true;
while(done) {
display_menu ();
cout << "Enter Choice: ";
cin >> choice;
switch (choice)
{
case TRANSFER:
transfer (checking, savings);
break;
case WITHDRAW:
withdraw (checking);
break;
case CHECK:
withdraw (checking);
break;
case DEPOSIT:
deposit (checking);
break;
case EXIT:
done = false;
break;
}
display_balances (checking, savings);
}
return 0;
}•
•
Join Date: Dec 2004
Posts: 27
Reputation:
Solved Threads: 0
or if you still want your orignal do while loop, change the condition inside the while... like this one:
C++ Syntax (Toggle Plain Text)
do { // statement } while(done==false);
![]() |
Similar Threads
- I'm struggling trying to complete the rest of my C++ program (file I/O, structs) (C++)
- Problem with contest program (C++)
- help in c++ program (C++)
- Still need info on calling a function from bool! (C++)
- Calling a fuction from a bool? (C++)
- GDI (C)
Other Threads in the C++ Forum
- Previous Thread: Sending email from c++ application
- Next Thread: Randomize number with OpenGL
| Thread Tools | Search this Thread |
api array arrays based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets





