f=count/num-1; //gives the frequency of a character in the array
Since count < num you will get f = 0. (eg. 3/5 = 0 NOT 0.6.) Also, are you sure the quantity is right? For example f = 3.0/6.0 - 1.0 = 0.5 - 1.0 = -0.5. Without () in the denominator that's what you'd get.if (coderead[i]==1)
for? This would test for a character with ascii value = 1 (which is a smiley-face). Aren't you looking for 'a' through 'z'?I'm guessing that when I check the frequencies, I need to store them into another array... |
int letterCount[26] = {0};
|
|
letterCount[coderead[i]-'a']++;
This gives the array index = offset from the letter a.
|
|
|
|