ABL electronic PIC16 Personal Computer User Manual


 
Structure Assignment
Variables of same structured type may be assigned one to another by means of
simple assignment operator (
=). This will copy the entire contents of the variable
to destination, regardless of the inner complexitiy of a given structure.
Note that two variables are of same structured type only if they were both defined
by the same instruction or were defined using the same type identifier. For exam-
ple:
/* a and b are of the same type: */
struct {int m1, m2;} a, b;
/* But c and d are _not_ of the same type although
their structure descriptions are identical: */
struct {int m1, m2;} c;
struct {int m1, m2;} d;
Size of Structure
You can get size of the structure in memory by means of operator
sizeof. Size of
the structure does not necessarily need to be equal to the sum of its members’
sizes. It is often greater due to certain limitations of memory storage.
Structures and Functions
A function can return a structure type or a pointer to a structure type:
mystruct func1();
// func1() returns a structure
mystruct *func2();
// func2() returns pointer to structure
A structure can be passed as an argument to a function in the following ways:
void func1(mystruct s);
// directly
void func2(mystruct *sptr);
// via pointer
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
76
MikroElektronika:
Development
tools
-
Books
-
Compilers
page