Anonymous user
Array: Difference between revisions
m
→C: lang tag / - nbsp
(not a task; don't use {{header}}) |
m (→C: lang tag / - nbsp) |
||
Line 37:
We wish to open a text file and compute letter frequency
/* declare array */
int frequency[26];
/* declare a computed index */
int ch;
any_text = fopen ("a_text_file.txt", "rt");
/* init the freq table: */
for (ch = 0; ch < 26; ch++)
frequency[ch] = 0;
ch = fgetc(any_text);
while (!feof(any_text)) {
Line 55:
frequency[ch-'A'] += 1;
ch = fgetc(any_text);
}</lang>
===[[J]]===
|