Pointers - mikroElektronika PIC Microcontrollers PIC12 User Manual

Mikroc user's manual
Table of Contents

Advertisement

mikroC
making it simple...
mikroC - C Compiler for Microchip PIC microcontrollers

Pointers

Pointers are special objects for holding (or "pointing to") memory addresses. In C,
address of an object in memory can be obtained by means of unary operator
. To
&
reach the pointed object, we use indirection operator (
) on a pointer.
*
A pointer of type "pointer to object of type" holds the address of (that is, points to)
an object of type. Since pointers are objects, you can have a pointer pointing to a
pointer (and so on). Other objects commonly pointed at include arrays, structures,
and unions.
A pointer to a function is best thought of as an address, usually in a code segment,
where that function's executable code is stored; that is, the address to which con-
trol is transferred when that function is called.
Although pointers contain numbers with most of the characteristics of unsigned
integers, they have their own rules and restrictions for declarations, assignments,
conversions, and arithmetic. The examples in the next few sections illustrate these
rules and restrictions.
Note: Currently, mikroC does not support pointers to functions, but this feature
will be implemented in future versions.
Pointer Declarations
Pointers are declared same as any other variable, but with
ahead of identifier.
*
Type at the beginning of declaration specifies the type of a pointed object. A point-
er must be declared as pointing to some particular type, even if that type is
,
void
which really means a pointer to anything. Pointers to
are often called gener-
void
ic pointers, and are treated as pointers to
in mikroC.
char
If type is any predefined or user-defined type, including void, the declaration
type *p;
/* Uninitialized pointer */
declares
to be of type "pointer to
". All the scoping, duration, and visibility
p
type
rules apply to the p object just declared. You can view the declaration in this way:
if
is an object of
, then
has to be a pointer to such objects.
*p
type
p
page
68
MikroElektronika: Development tools - Books - Compilers

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?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Pic microcontrollers pic16Pic microcontrollers pic18

Table of Contents