From 04959332f2b8a4638e222b9829ec7fba1832371e Mon Sep 17 00:00:00 2001 From: Emma Nora Theuer Date: Mon, 28 Oct 2024 13:47:25 +0100 Subject: [PATCH] Fixed a bug where is_num() and is_int() returned true when a letter was entered. --- Übung 2/util.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Übung 2/util.c b/Übung 2/util.c index 1f96ab3..81bd537 100644 --- a/Übung 2/util.c +++ b/Übung 2/util.c @@ -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++; }