help with do-while loop!!

This is a discussion on help with do-while loop!! within the C++ Programming forums, part of the General Programming Boards category; Hi. I have nearly finished a program i am writimg but am having trouble with the last thing i need ...

help with do-while loop!!

Hi. I have nearly finished a program i am writimg but am having trouble with the last thing i need to put in. All it is, is a do while loop that will loop that part of the program until the correct input has been entered. Which means the user cant enter a letter instead of a number or the wrong number. But for some reason it doesn't want to work. I have various other do while loops in the program and they all work fine. I also use the choice made to return a statement from the switch statement later in the program as you can see.

The ones that aren't working are the one's for the first two choices that are made. I tried making a do while loop that would repeat until a number from 1 to 10 was entered which worked fine when entering other numbers apart from 1 to 10 but when i enter a letter it just freezes and the program flickers. I also tried changing it so it asked for a letter from a to j instead but when putting a do while loop that repeated until a letter from a to j was input it really didn't like it. Can anyone help? it would be much appreciated. I have put a segment of the prgram in so you can see what i have so far. I have left in my attempt at the do while loop for the first selection bit ( commented as NOT WORKING!!! ).

Could you please explain what is meant by parse. Not sure what that means.

I've changed the limits in the do-while loop as stated by MK27 (it clicked when i saw it, should have wrote it like that the first time DOH!) but still no joy. When i changed it to 'gets' it went haywire and brought up all kinds of jargon and my program was gone.

Vart, i know what you mean with the 'ret' needing to be %c but for some reason it didn't work and when i changed it to %s it worked so i left it. Probably not the proper way to do it but its the only way i could get it working.

Thanks again. Your help is much appreciated. Its just very frustating when you cant get it working, especially when its something quite simple and especially when its something that is working elsewhere in the program under the exact same format

It's probably easier to change to chars (since a number is a character, but a character is not necessarily a number) if you're concerned about people typing weird things. But you can't read characters with %s, you need %c.

I see what you mean now. Maybe chars would be better. If make the selection a to j insted of 1 to 10 i still have trouble getting it to work. Someone told me it could be registering the return key after the entered character aswell meaning it could possibly be a string. Is there a way of not having to press return key afterwards??
Thanks