User manual

210
mikoC PRO for dsPIC
MikroElektronika
//array of pointer to functions that receive two chars and returns int
int (*arrpf[])(char,char) = { addC ,subC,mulC,divC,modC};
int res;
char i;
void main() {
for (i=0;i<5;i++){
res = arrpf[i](10,20);
}
}
Pointer Arithmetic
Pointer arithmetic in the mikroC PRO for dsPIC30/33 and PIC24 is limited to:
- assigning one pointer to another,
- comparing two pointers,
- comparing pointer to zero,
- adding/subtracting pointer and an integer value,
- subtracting two pointers.
The internal arithmetic performed on pointers depends on the memory specier in force and the presence of any
overriding pointer modiers. When performing arithmetic with pointers, it is assumed that the pointer points to an array
of objects.
Arrays and Pointers
Arrays and pointers are not completely independent types in the mikroC PRO for dsPIC30/33 and PIC24. When the
name of an array comes up in expression evaluation (except with operators & and sizeof), it is implicitly converted to
the pointer pointing to array’s rst element. Due to this fact, arrays are not modiable lvalues.
Brackets [ ] indicate array subscripts. The expression
id[exp]
is dened as
*((id) + (exp))
where either:
- id is a pointer and exp is an integer, or
- id is an integer and exp is a pointer.