Assignment operators, Mikroc – ABL electronic PIC Microcontrollers PIC16 User Manual

Page 118

Advertising
background image

4. Both of type pointer to qualified or unqualified versions of compatible types.

The resulting type is a pointer to a type qualified with all the type qualifiers of
the types pointed to by both operands.

5. One operand is a pointer, and the other is a null pointer constant. The resulting

type is a pointer to a type qualified with all the type qualifiers of the types
pointed to by both operands.

6. One operand is a pointer to an object or incomplete type, and the other is a

pointer to a qualified or unqualified version of

void

. The resulting type is that

of the non-pointer-to-

void

operand.

Assignment Operators

Unlike many other programming languages, C treats value assignment as an oper-
ation (represented by an operator) rather than instruction.

Simple Assignment Operator

For a common value assignment, we use a simple assignment operator (=) :

expression1

=

expression2

Expression1

is an object (memory location) to which we assign value of

expression2

. Operand

expression1

has to be a lvalue, and

expression2

can

be any expression. The assignment expression itself is not an lvalue.

If

expression1

and

expression2

are of different types, result of the

expres-

sion2

will be converted to the type of

expression1

, if necessary. Refer to Type

Conversions for more information.

Compound Assignment Operators

C allows more comlex assignments by means of compound assignment operators.
Syntax of compound assignment operators is:

expression1 op

=

expression2

where

op

can be one of binary operators

+

,

-

,

*

,

/

,

%

,

&

,

|

,

^

,

<<

, or

>>

.

mikroC - C Compiler for Microchip PIC microcontrollers

mikroC

making it simple...

110

MikroElektronika: Development tools - Books - Compilers

page

Advertising
This manual is related to the following products: