fix: change pointer type to const in recursive character count function

This commit is contained in:
MarcUs7i 2025-01-10 23:29:50 +01:00
parent ef3a27fa78
commit 6cecc84d30

View file

@ -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 // 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 // true is 1, false is 0. no need to write a ternary operator
return (str[0] == c) + count_char_recursive(truncated, c); return (str[0] == c) + count_char_recursive(truncated, c);