fix: change pointer type to const in recursive character count function
This commit is contained in:
parent
ef3a27fa78
commit
6cecc84d30
1 changed files with 1 additions and 1 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue