Fixed a bug where is_num() and is_int() returned true when a letter was entered.

This commit is contained in:
Emma Nora Theuer 2024-10-28 13:47:25 +01:00
parent f9e4f13bfe
commit 04959332f2

View file

@ -15,13 +15,13 @@ bool is_num(char *str) {
return false; return false;
} }
while (*str) { while (*str) {
if (!isdigit((unsigned char)*str) || !(*str == '.')) { if (!isdigit((unsigned char)*str)) {
return true; return false;
} }
str++; str++;
} }
return false; return true;
} }
bool is_int(char *str) { bool is_int(char *str) {
@ -33,7 +33,7 @@ bool is_int(char *str) {
} }
while (*str) { while (*str) {
if (!isdigit((unsigned char)*str)) { if (!isdigit((unsigned char)*str)) {
return true; return false;
} }
str++; str++;
} }