i tried to run this code,
#include <cs50.h>
#include <stdio.h>
#include <ctype.h>
int main()
{
int iRandom = 0;
int iResponse = 0;
iRandom = (rand() % 10) + 1;
printf("\nGuess a number between 1 and 10: \n");
scanf("%d", &iResponse);
if isdigit(iResponse)
printf("\nProcessing.....\n");
else
printf("You did not enter a digit!\n");
{
if(iResponse == iRandom)
printf("\nYou guessed right\n");
else
printf("You guessed wrong\n");
printf("\nThe correct guess was %d\n", iRandom);
}
}
but the isdigit()
function keeps processing it wrong even though my input was a digit;
/home/ubuntu/workspace/fooling/ $ ./guess
Guess a number between 1 and 10:
5
You did not enter a digit!
You guessed wrong
The correct guess was 4
can you tell me what i did wrong?