#include #include #include // check that chars from i to end are all digits bool digcheck_helper(char * str, int i) { printf("i is %d\n", 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 bool flag = digcheck_helper(str, i + 1); printf("i again %d\n",i); return flag; //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] = "12y333"; if (digcheck(s)) printf("ok\n"); else printf("not ok\n"); }