Harkirat Kaur
PRO
last month
Harkiratcountry asked

I don’t get why isdigit() returns 2048 when the character is a digit. Why not just 1?

Abhay Jajodia
Expert
last month
Abhay Jajodia answered

Hi Harkirat, in C, isdigit() returns 0 for false and any non-zero number for true, and the exact “true” number can be different depending on the system. So 2048 still just means true.

printf("%d\n", isdigit('8')); // non-zero means true (could be 2048)

If you have more questions, I am here to help.

C
This question was asked as part of the Learn C Programming course.