Я понятия не имею, почему isdigit()
и isalpha()
продолжают делать это. Независимо от того, как я их использую, они всегда возвращают 0
. Я использую их неправильно или мой компилятор действует?isalpha() и isdigit() всегда возвращаются 0
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
//example of isdigit not working, it ALWAYS returns 0 no matter what the input is.
int main()
{
int num=0;
int check=0;
printf("Enter a number: ");
fflush(stdin);
scanf("%d",&num);
//Just checking what value isdigit has returned
check=isdigit(num);
printf("%d\n",check);
if(check!=0)
{
printf("Something something");
system("pause");
return 0;
}
else
{
system("pause");
return 0;
}
}
Конечно, вы их используете неправильно. '0' не' '0'',' 1' не '' 1'' и т. Д. –
scanf ("% d", &num); => scanf ("% c", & digit); – Jekyll