I'm a complete beginner doing the cs50 course and I need to check if an argument from a user is a digit or not.
this is the code:
#include <stdio.h>
#include <cs50.h>
#include <ctype.h>
int main(void)
{
int i = 1;
if (isdigit(i) == 1)
{
printf("i is a digit");
}
else if (isdigit(i) == 0)
{
printf("i is not a digit");
}
return 0;
}
When I run this code I basically get a reverse of what I should be getting. When i is a number it prints out "i is not a number" and visa versa. What am I doing wrong? I thought isdigit returns a non-zero value if it is a digit and 0 if not. Basically 1 being true and 0 being false. Is this not correct? Much appreciated, Thanks!