optimizing loop (frequency counting)... HELP
okay. i am trying to make this loop run as quick as possible.
i am trying to collect all occurances of each ASCII character and put into table. i don't really care if ASCII char value equals it's position in the table.
Code:
for (;;) {
c = fgetc(input_file);
/* If symbol is already in table then increase frequency
* by one, otherwise put symbol into the table.
*/
for (i = 0; i < 256; i++) {
if(c == i) {
if (symbol[i].achar == c) {
symbol[i].count++;
break;
}
symbol[i].achar = c;
}
}
nc++;
if (feof(input_file))
break;
}