problm o........ing ASCII frequencies
I have written this :
Code:
#include <stdio.h>
#define ASCII_VALUES 256
int
main(int argc, char **argv) {
int i, ch;
int frequency[ASCII_VALUES];
for (i = 0; i < ASCII_VALUES; i++)
{
frequency[i] = 0;
}
printf("Enter some text to count the frequency of the characters: ");
while ((ch=getchar()) != EOF)
{
if (frequency[ch]!=0)
{
frequency[ch] += 1;
}
else
{
frequency[ch] = 1;
}
}
printf("Character Frequency");
for (i = 0; i < ASCII_VALUES; i++)
{
if (frequency[i] != 0 )
{
printf("%c %d\n", i, frequency[i]);
}
}
return 0;
}
I cant see what is wrong with it, but it isn't counting the frequencies...