mikroElektronika PIC Microcontrollers PIC12 User Manual page 86

Mikroc user's manual
Table of Contents

Advertisement

mikroC - C Compiler for Microchip PIC microcontrollers
Accessing Nested Structures
If structure
accessed by two applications of the member selectors:
struct A {
int j; double x;
};
struct B {
int i; struct A a; double d;
} s, *sptr;
//...
s.i = 3;
s.a.j = 2;
sptr->d = 1.23;
sptr->a.x = 3.14;
Structure Uniqueness
Each structure declaration introduces a unique structure type, so that in
struct A {
int i,j; double d;
} aa, aaa;
struct B {
int i,j; double d;
} bb;
the objects
different structure types. Structures can be assigned only if the source and destina-
tion have the same type:
aa = aaa;
aa = bb;
/* but you can assign member by member: */
aa.i = bb.i;
aa.j = bb.j;
aa.d = bb.d;
page
78
contains a field whose type is structure
B
// assign 3 to the i member of B
// assign 2 to the j member of A
// assign 1.23 to the d member of B
// assign 3.14 to x member of A
and
are both of type struct
aa
aaa
/* OK: same type, member by member assignment */
/* ILLEGAL: different types */
MikroElektronika: Development tools - Books - Compilers
, the members of
A
, but the objects
and
A
aa
mikroC
making it simple...
can be
A
are of
bb

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