|
-
Oct 21st, 2001, 07:35 PM
#1
Thread Starter
Addicted Member
Finding out if value is numeric
Hi,
Just wondering, In c, if i use this code snippit:
Code:
int value;
printf("Please enter a value: ");
scanf("%d", &value);
how can i then check that value is a numeric value, i know that by declaring it as int it should be numeric, but i have made a menu system that dispalys some options and the user has to enter a number that currosponds to the selection they want to use.
This works great if the user enters a number, but if a user hits a letter key by mistake, then the menu is just displayed over and over again, without stopping.
Maybe i need a way to allow the user to only enter numbers and no letters, is that a possibility, and if so, could you please post some sample code for me (the code needs to be in c, and will be used in a console app)..
Thanks for your help.
-|- Hurgh -|-
Email: [email protected]
Website: http://www.hurgh.org/
Unix, Linux, FreeBSD, OpenBSD, Solaris, Windows
C, C++, PHP, VB6, ASP, VBScript, JavaScript
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|