Skip to content

Latest commit

 

History

History
49 lines (32 loc) · 1.02 KB

README.md

File metadata and controls

49 lines (32 loc) · 1.02 KB

Array Allocation and Access

Array in C are one means of aggregating scalar data into larger data types.

For example:

char A[12];
char *B[8];
int  C[6];
double *D[5];
Array Element size Total size Start address Element i
A 1 12 x x + i
B 8 64 x x + 8 * i
C 4 24 x x + 4 * i
D 8 40 x x + 8 * i

Practice:

Pointer Arithmetic

Pay attention: the array reference A[i] is identical to the expression *(A+i).

Practice:

Nested Arrays

For an array declared as:

T D[R][C];

Any element of D[i][j] is at memory address:

$&D[i][j] = x_d + L(C * i + j)$

Practices: