So I have a function that is called everytime the user inputs something, to check whether it is a number or, includes letters aswell. But I want the user to be able to input a decimal, such as 1.234 or 0.4354 etc. I also want the user to be able to input negative numbers, and fractions.

Here is my function at the moment,

It should only be checking to see whether the letter is a decimal point, and if so allow it, but it doesnt work. I am going to also make if statements checking whether the first letter is a - sign and allow that in a similar manner.Code:int is_digit(char* digit) { int len=strlen(digit); int i; for(i=0;i<len;i++) { if(isdigit(digit[i])==0) { if ((digit[i]) == ".") { } else { return -1; } } } return atoi(digit); }

Please can someone sport whats wrong.

Thanks