User manual

Table Of Contents
mikroC PRO for PIC32
MikroElektronika
207
//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 PIC32 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 PIC32. 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.