isdigit() Function Again -_-
Code:
#include <stdio.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
int main()
{
int iRandNum = 0;
int iUserGuess = 0;
srand(time(NULL));
iRandNum = (rand() % 10) + 1;
printf("Guess the number from 1 to 10\n");
scanf("%i", &iUserGuess);
if (isdigit(iUserGuess) == 0)
{
printf("Invalid Entry, Not a number!\n");
}
else if (isdigit(iUserGuess) && iUserGuess == iRandNum)
{
printf("You guessed it!\n");
}
else if (isdigit(iUserGuess) && iUserGuess != iRandNum)
{
printf("Wrong Guess! Number was: %i\n", iRandNum);
}
return 0;
}
Could someone please explain the isdigit function a bit better, because that's the problem with it.. But I'm not sure how exactly I'm supposed to be using it and why this isn't working, Thanks.