ive got caught in a forever loop

S

Sokar

Hello,

I was wondering if anyone could help me out. I have devised a wee
menu system with 5 options. the way to select an option is to select
a number 1 - 5 and then there is a switch block to implement some code
depending on the selection. before the program goes into the switch i
have an if statement which checks the see if the input from the user
is greater than 5 "if(choice > 5)" if so then it calls the main
function and goes back to the start. If not then it goes into the
switch statement.

The problem is that if the user enters a letter as their choice
instead of a number the program goes into a forever loop and keeps
displaying the menu over and over again.

I was wondering if anyone know how I could test to see if the entry by
the user was either greater than 5 or not numerical in value.

Thanks and regards

John
 
O

osmium

Sokar said:
I was wondering if anyone could help me out. I have devised a wee
menu system with 5 options. the way to select an option is to select
a number 1 - 5 and then there is a switch block to implement some code
depending on the selection. before the program goes into the switch i
have an if statement which checks the see if the input from the user
is greater than 5 "if(choice > 5)" if so then it calls the main
function and goes back to the start. If not then it goes into the
switch statement.

The problem is that if the user enters a letter as their choice
instead of a number the program goes into a forever loop and keeps
displaying the menu over and over again.

I was wondering if anyone know how I could test to see if the entry by
the user was either greater than 5 or not numerical in value.

There was a similar question on this newsgroup a few days ago. Take a look
at this thread.


http://groups-beta.google.com/group..."please+tell+me+what"&rnum=6#0fbbda29a7c73cec
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top