I am wanting to add a second portion to a validation function for a float to trap if a 2nd decimal point is accidently entered.
Right now it just ignores the 2nd decimal point and the following digit.Code:int sValidFloatString(char *chFloat) { // Declare Variables for Function float flValidEntry = 0.0; int i = 0; char chStringEnd = '\0'; char chDot = '.'; //Check each chararacter in string for validity while(chFloat[i]!=chStringEnd) { //If entered character not a valid number, return invalid and exit function if(isdigit(chFloat[i])!=0 || (chFloat[i]==chDot)) { //Valid entry flValidEntry = 1; } else { //Invalid entry, end function flValidEntry = 0; break; } //Movenext i++; } return flValidEntry; } // ********** End Function ************ Example: User input: 1.23.2 Output: Invalid Entry
Thank you in advance
ropewrench