mikroElektronika PIC Microcontrollers PIC12 User Manual page 79

Mikroc user's manual
Table of Contents

Advertisement

mikroC
making it simple...
According to these guidelines, we can write:
pa = &a[4];
x = *(pa + 3);
y = *pa + 3;
Also, you need to be careful with operator precedence:
*pa++;
(*pa)++;
Following examples are also valid, but better avoid this syntax as it can make the
code really illegible:
(a + 1)[i] = 3;
// same as: *((a + 1) + i) = 3, i.e. a[i + 1] = 3
(i + 2)[a] = 0;
// same as: *((i + 2) + a) = 0, i.e. a[i + 2] = 0
Assignment and Comparison
You can use a simple assignment operator (
another if they are of the same type. If they are of different types, you must use a
typecast operator. Explicit type conversion is not necessary if one of the pointers is
generic (of
Assigning the integer constant 0 to a pointer assigns a null pointer value to it. The
mnemonic
can be used for legibility.
Two pointers pointing into the same array may be compared by using relational
operators
were used on subscript values of array elements in question:
int *pa = &a[4], *pb = &a[2];
if (pa > pb) {
// this will be executed as 4 is greater than 2
}
MikroElektronika: Development tools - Books - Compilers
mikroC - C Compiler for Microchip PIC microcontrollers
// pa points to a[4]
// x = a[7]
// y = a[4] + 3
// is equal to *(pa++), increments the pointer!
// increments the pointed object!
type).
void
(defined in the standard library header files, such as
NULL
,
,
,
,
, and
==
!=
<
<=
>
>=
...
) to assign value of one pointer to
=
. Results of these operations are same as if they
)
stdio.h
page
71

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the PIC Microcontrollers PIC12 and is the answer not in the manual?

This manual is also suitable for:

Pic microcontrollers pic16Pic microcontrollers pic18

Table of Contents