6.1.7 Arrays and pointers
Arrays
The interpreter allows use of arrays with an amount of dimensions only limited by the
memory capacity. Nevertheless tables of more than 2 or 3 dimensions are rare.
int tab_4[2][12][31][2]
Note that if you refer to the name of a table without the brackets, you will not get an
error. C will give you the address of the first element of the table.
&tab_4[0][0][0][0] is equal to tab_4
Initializing arrays
The interpreter let you initialize simple variables, but you cannot initialize arrays as
easily:
char *month[12]={“Jan”,”Feb”,”Mar”, … ,”Dec”};
which is allowed in ANSI C will generate an “illegal initialization error”. Use instead:
char *month[12];
month[0]=“Jan”; month[1]=”Feb”; … ; month[11]=”Dec”;
Pointers
The pointer is a 16-bit variable that holds the address of a variable. For example:
x = *px;
Here, the content at the address pointed to by px is assigned to variable x. Note the
following:
px = &x;
y = *px;
Here, the address of variable x is assigned to pointer px. Then, the content at the
address pointed to by px is assigned to variable y. Consequently, this is equivalent
to:
y = x;