How to prevent users from inputting letters or numbers ?

Posted by ZaZu on Stack Overflow See other posts from Stack Overflow or by ZaZu
Published on 2010-05-09T00:02:52Z Indexed on 2010/05/09 0:08 UTC
Read the original article Hit count: 175

Filed under:
|
|

Hello,

I have a simple problem;

Here is the code :

#include<stdio.h>
main(){
 int input;
 printf("Choose a numeric value");
 scanf("%d",&input);
}

I want the user to only enter numbers ... So it has to be something like this :

#include<stdio.h>
main(){
 int input;
 printf("Choose a numeric value");
 do{
   scanf("%d",&input);
 }while(input!= 'something');
}

My problem is that I dont know what to replace in 'something' ... How can I prevent users from inputting alphabetic characters ?

Thanks for your help ! }

© Stack Overflow or respective owner

Related posts about c

    Related posts about limit-choices-to