A True Canadian
Newbie
- Joined
- Aug 29, 2003
- Messages
- 2,874
- Reaction score
- 2
I've run into a problem dealing with characters.
What I want is for the user to enter in one of two values:
'p' for pounds
'k' for kilograms
...and if they enter neither 'p' or 'k', the program repeats: asking the user to re-enter a value again.
The question is, how would I go about setting that up in C++?
I know I will need to use a loop of some kind, but my attempts so far have failed. I can't get the program to read the inputs properly, and as a result my program crashes. Something about the characters that needs fixing up.
This portion of my program is supposed to do a conversion from metric units to the English system. I have everyting completed, except this small part.
If they choose pounds, the program should proceed in the English system.
If the user chooses kilograms, the program should proceed in the metric system.
And, of course, if they fail at correctly choosing pounds or kilograms, the program should ask them to try again.
I'll likely be laughing at this once this problem gets figured out. Having a bit of a brain cramp today.
What I want is for the user to enter in one of two values:
'p' for pounds
'k' for kilograms
...and if they enter neither 'p' or 'k', the program repeats: asking the user to re-enter a value again.
The question is, how would I go about setting that up in C++?
I know I will need to use a loop of some kind, but my attempts so far have failed. I can't get the program to read the inputs properly, and as a result my program crashes. Something about the characters that needs fixing up.
This portion of my program is supposed to do a conversion from metric units to the English system. I have everyting completed, except this small part.
If they choose pounds, the program should proceed in the English system.
If the user chooses kilograms, the program should proceed in the metric system.
And, of course, if they fail at correctly choosing pounds or kilograms, the program should ask them to try again.
I'll likely be laughing at this once this problem gets figured out. Having a bit of a brain cramp today.