I am having problems counting the frequency of all characters in a given array. This is my code so far. For some reason, all it outputs is 0. What should i change? I can't see the problem as i think i am incrementing d the right way.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <iostream>
#include <cstring>
usingnamespace std;
int main()
{
int f[26]={0};
char text[200];
cin.get(text, 200);
char i;
for(i=0;i<strlen(text);i++){
int d=i-'a';
f[d++];
}
for(int j=0;j<26;j++){
cout<<char(j+'a')<<" apare de "<<f[i]<<endl;
}
return 0;
}