I need to input 1 to 3 numbers with values between 3 to 69 only. So when I input something different from a number the program should fprintf on stderr "The input isn't number". But I cannot find a way how to code that. And I should use if function.
#include <stdio.h>
int main()
{
int i=0;
while (scanf("%d", &i) == 1)
{
if (i<3 || i>69)
{
fprintf(stderr,"Error: Input is too big or too small!");
return 101;
}
if (ISNT A NUMBER)
{
fprintf(stderr,"Error: Input isnt a number!");
return 100;
}
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire