#include <iostream>
#include <string>
void countDigits(std::string s) {
if (s.empty()) {
printf("String is empry");
return;
}
int digit_frequency[10] = { 0 };
int i = 0;
while (s[i] != 0) {
if (isdigit(s[i])) {
digit_frequency[s[i] - '0']++;
}
i++;
}
for (int i = 0; i < 10; i++) {
std::cout << i << ": " << digit_frequency[i] << " times\n";
}
}
int main()
{
std::string s = "c23c++4523java23988rust82215";
countDigits(s);
}
/*
run:
0: 0 times
1: 1 times
2: 5 times
3: 3 times
4: 1 times
5: 2 times
6: 0 times
7: 0 times
8: 3 times
9: 1 times
*/