util.c (415B)
1 #include<ctype.h> 2 #include<stdlib.h> 3 #include<string.h> 4 #include"bibleverse.h" 5 6 int isNumber(char* string) { 7 int len = strlen(string); 8 char* termstr = malloc((len + 1) * sizeof(char*)); 9 char* termstr_orig = termstr; 10 strcpy(termstr, string); 11 termstr[len] = '\0'; 12 13 while(*termstr != '\0') { 14 if(!isdigit(*termstr)) { 15 free(termstr_orig); 16 return 0; 17 } 18 ++termstr; 19 } 20 21 free(termstr_orig); 22 23 return 1; 24 } 25