#include #include #include // check that chars from i to end are all digits bool digcheck_helper(char * str, int i) { if (str[i] == '\0') { // no more characters, so valid return true; } else if (str[i] >= '0' && str[i] <= '9') { // str[i] is a digit, check rest recursively return digcheck_helper(str, i + 1); } else { // str[i] is not a digit return false; } } //make sure all the characters are digits //uses a helper function to get it started bool digcheck(char * str) { return digcheck_helper(str, 0); } int main() { printf("hello world\n"); char s[10] = "12333i"; if (digcheck(s)) printf("ok\n"); else printf("not ok\n"); }