Fixed a bug where is_num() and is_int() returned true when a letter was entered.
This commit is contained in:
parent
f9e4f13bfe
commit
04959332f2
1 changed files with 4 additions and 4 deletions
|
@ -15,13 +15,13 @@ bool is_num(char *str) {
|
|||
return false;
|
||||
}
|
||||
while (*str) {
|
||||
if (!isdigit((unsigned char)*str) || !(*str == '.')) {
|
||||
return true;
|
||||
if (!isdigit((unsigned char)*str)) {
|
||||
return false;
|
||||
}
|
||||
str++;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool is_int(char *str) {
|
||||
|
@ -33,7 +33,7 @@ bool is_int(char *str) {
|
|||
}
|
||||
while (*str) {
|
||||
if (!isdigit((unsigned char)*str)) {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
str++;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue