On this page
isdigit
Prev: ctype.h | Up: ctype.h | Next: isalpha
Rel: ctype.h, Arrays & C Strings
Ref: cppreference — isdigit
Tags: #public #prog #c #stdlib #ctype #tier/core
Include
#include <ctype.h>
Signature & Overview
int isdigit(int ch);
Returns non-zero if ch is an ASCII decimal digit '0'–'9'.
Notes & Pitfalls
- Always cast
(unsigned char)c: Only matches ASCII'0'..'9'regardless of locale.
Example
#include <assert.h>
#include <ctype.h>
int main(void) {
assert(isdigit((unsigned char)'7') != 0);
assert(isdigit((unsigned char)'a') == 0);
}
Linked from
Related notes
- tuts/c/stdlib/ctype/isalpha Linked here; links to this page; shared tags: #c, #ctype, #prog, #stdlib, #tier
- tuts/c/stdlib/ctype Linked here; links to this page; shared tags: #c, #ctype, #prog, #stdlib
- tuts/c/fundamentals/arrays_and_strings Linked here; shared tags: #c, #prog
- tuts/c/stdlib/ctype/isspace shared tags: #c, #ctype, #prog, #stdlib, #tier
- tuts/c/stdlib/ctype/tolower shared tags: #c, #ctype, #prog, #stdlib, #tier
- tuts/c/stdlib/assert/assert shared tags: #c, #prog, #stdlib, #tier
- tuts/c/stdlib/assert/static_assert shared tags: #c, #prog, #stdlib, #tier
- tuts/c/stdlib/errno/errno shared tags: #c, #prog, #stdlib, #tier
- tuts/c/stdlib/limits/CHAR_BIT shared tags: #c, #prog, #stdlib, #tier
- tuts/c/stdlib/limits/DBL_EPSILON shared tags: #c, #prog, #stdlib, #tier