Jump to content

Array: Difference between revisions

no edit summary
(explain arrays, really!)
No edit summary
Line 4:
 
All values between (and including) the lower and the upper bound of the array may legally be accessed during the program run.
 
==Examples==
===C===
We wish to open a text file and compute letter frequency
 
FILE *any_text;
/* 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;
&nbsp;
ch = fgetc(any_text);
while (!feof(any_text))
if (is_a_letter(ch))
/* if a letter increase character slot in the freq table: */
frequency[ch-'A'] += 1;
 
==Computational metrics==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.