How to prevent users from typing incorrect inputs ?

Posted by ZaZu on Stack Overflow See other posts from Stack Overflow or by ZaZu
Published on 2010-05-08T18:59:51Z Indexed on 2010/05/08 19:08 UTC
Read the original article Hit count: 178

Filed under:
|

Hello,

I want the program to loop a scan function if the user types anything else other than numbers..

My code is :

 do{
    printf("Enter rows\n");
    scanf("%d",&row);
  }while(row>='a' && row<='z');

but this code doesnt work .. I keep getting an error when typing in a letter. I tried manipulating around it and the whole thing loops infinitely ... What am I doing wrong ?

Please help thanks !

© Stack Overflow or respective owner

Related posts about error-handling

Related posts about c