diff --git a/x_ctypes/src/x_ctypes.c b/x_ctypes/src/x_ctypes.c index f49da04..f1d1cd7 100644 --- a/x_ctypes/src/x_ctypes.c +++ b/x_ctypes/src/x_ctypes.c @@ -11,3 +11,14 @@ int x_isdigit(const char x){ return 0; } +int x_isnumber(const char* str){ + const char * ptr; + + for (ptr = str; *ptr != '\0'; ptr++){ + if ( !x_isdigit(*ptr) ){ + return 0; + } + } + + return 1; +} diff --git a/x_ctypes/src/x_ctypes.h b/x_ctypes/src/x_ctypes.h index 3d08dab..9cb5141 100644 --- a/x_ctypes/src/x_ctypes.h +++ b/x_ctypes/src/x_ctypes.h @@ -4,5 +4,6 @@ // returns 0 if x is not a digit and 1 if it is int x_isdigit(char x); +int x_isnumber(char *str); #endif