11-recursion-algos/count_char.c

33 lines
1.1 KiB
C

/*----------------------------------------------------------
* HTBLA-Leonding
* ---------------------------------------------------------
* Title: Count Character Occurrence
* Author: Marc Tismonar
* ----------------------------------------------------------
* Description:
* Recursive and iterative implementation of an algorithm that
* counts the occurrences of a specific character within a string.
* ----------------------------------------------------------
*/
#include "count_char.h"
/*
Instructions:
Define a function count_char(s, c) that takes a string `s` and the character 'c' to count as input.
Increase the counter by one, if the character matches the character at
the current position within the string and add the count of that character in the remaining string
until the end of the string ('\0').
*/
// TODO: the recursive implementation
int count_char_recursive(const char* str, char c) {
return 0;
}
// TODO: the iterative implementation
int count_char_iterative(const char* str, char c) {
return 0;
}