The comparison input[c] < '0' && input[c] > '9' is is not right, this expression is never true, you should use >='0' && <='9' if you mean "between 0 and 9".
While it is not an error, the ok variable is not needed here. You could simply use return statements:
Code:int is_numeric(char input[256]) { int c; for(c = 0; input[c] != "\0";c++) { if(input[c] < '0' || input[c] > '9') { return 0; } } return 1; }




Reply With Quote