ABL electronic PIC12 Personal Computer User Manual


 
Pointer Arithmetic
Pointer arithmetic in C is limited to:
- assigning one pointer to another,
- comparing two pointers,
- comparing pointer to zero (
NULL),
- adding/subtracting pointer and an integer value,
- subtracting two pointers.
The internal arithmetic performed on pointers depends on the memory model in
force and the presence of any overriding pointer modifiers. 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 C. When name of the
array comes up in expression evaluation (except with operators
& and sizeof ), it
is implicitly converted to the pointer pointing to array’s first element. Due to this
fact, arrays are not modifiable lvalues.
Brackets
[ ] indicate array subscripts. The expression
id
[
exp
]
is defined as
*((
id
) + (
exp
))
where either:
id
is a pointer and
exp
is an integer, or
id
is an integer and
exp
is a pointer.
The following is true:
&a[i] = a + i
a[i] = *(a + i)
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
70
MikroElektronika:
Development
tools
-
Books
-
Compilers
page