From 6cecc84d308cf39dc22fb9608c72ab7a8304ee7f Mon Sep 17 00:00:00 2001 From: MarcUs7i Date: Fri, 10 Jan 2025 23:29:50 +0100 Subject: [PATCH] fix: change pointer type to const in recursive character count function --- count_char.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/count_char.c b/count_char.c index 947c3c2..58e3664 100644 --- a/count_char.c +++ b/count_char.c @@ -28,7 +28,7 @@ int count_char_recursive(const char* str, char c) { } // skips the first character by moving the pointer to the next character - char* truncated = str + 1; + const char* truncated = str + 1; // true is 1, false is 0. no need to write a ternary operator return (str[0] == c) + count_char_recursive(truncated, c);