•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 402,797 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,893 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 392 | Replies: 12
![]() |
•
•
Join Date: Jul 2008
Posts: 11
Reputation:
Rep Power: 1
Solved Threads: 0
•
•
•
•
This should be your code to start with, then you compile it to see what the result is. If it doesn't compile, then fix it.do{ } while (choice != 'c' && choice != 'C');
Then your code becomes
Compile it again, and fix any new errors.do{ cout << "A: To Play the number guessing game." << endl; cout << "B: To Play the letter game." << endl; cout << "C: To quit program." << endl; cin >> choice; } while (choice != 'c' && choice != 'C');
Then perhaps
Notice how you can add just a few lines at a time, and it will compile.do{ cout << "A: To Play the number guessing game." << endl; cout << "B: To Play the letter game." << endl; cout << "C: To quit program." << endl; cin >> choice; } while (choice != 'c' && choice != 'C'); switch (choice) { case 'A': case 'a': break; }
When you've done this a few times, then test what you've written so far to make sure it actually works as expected. If it doesn't, then fix those before adding more code.
In particular, note that the { } are never left out of place, or unbalanced.
What you've done is code beyond your ability to deal with the compiler throwing the whole mess back at you, so instead you dump it on a message board for someone else to fix. This isn't a good long term strategy.
I am sorry I came to message board to ask for help on something. I thought that was what it was used for. also if I filled in my program they way you have it above.
do{
cout << "A: To Play the number guessing game." << endl;
cout << "B: To Play the letter game." << endl;
cout << "C: To quit program." << endl;
cin >> choice;
} while (choice != 'c' && choice != 'C');
switch (choice)
{
case 'A':
case 'a':
break;
}It wouldn't have compiled right anyway cause I need the while after the switch like so.
do{
cout << "A: To Play the number guessing game." << endl;
cout << "B: To Play the letter game." << endl;
cout << "C: To quit program." << endl;
cin >> choice;
switch (choice)
{
case 'A':
case 'a':
break;
}
} while (choice != 'c' && choice != 'C');This works like a charm on my program. Sorry I dumped my problem on you.
> Salem was trying to teach you a better way to fish
Exactly!
Exactly!
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Do not PM me for help; You'll be ignored, or told to learn to read.
Do not ask me if I'm muslim - I'm not. Nor do I care about yours or anyone else's mysticism. Religion is a matrix, take the RED PILL.
Do not PM me for help; You'll be ignored, or told to learn to read.
Do not ask me if I'm muslim - I'm not. Nor do I care about yours or anyone else's mysticism. Religion is a matrix, take the RED PILL.
![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Game Development FAQ's, Books and Resources (Game Development)
- Multiple key check (C++)
- lots of problems with my simple game (C++)
- game needs more adversaries (Java)
- Making Text Based Game (Game Development)
- school project: simple C++ game (need help with keyboard input) (C++)
- VB6 oRPG game: Book of Souls (Visual Basic 4 / 5 / 6)
- Computer Engeering (Pascal and Delphi)
- build java game (Java)
Other Threads in the C++ Forum
- Previous Thread: Visual C++ 2008 playing a sound
- Next Thread: Arrays



Linear Mode