EasyManua.ls Logo

Casio FX-890P - Arrays and Pointers

Casio FX-890P
126 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
107
Note: The interpreter does not allow declaring a local “auto” variable within the code
of a function.
func(a)
double a;
{
int i,j,x;
float fx,fy;
long lx,ly;
for(i=0;i<5;i++){
}
}
func(a)
double a;
{
int i,j,x;
long lx,ly;
for(i=0;i<5;i++){
float fx,fy;
}
}
func(a)
double a;
{
int i,j;
float fx,fy;
long lx,ly;
for(i=0;i<5;i++){
int x;
}
}
Program A: OK
Program B: Error
Program C: Error
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;

Table of Contents

Related product manuals