mikroC
making it simple...
Structure Member Access
mikroC - C Compiler for Microchip PIC microcontrollers
Structure and union members are accessed using the following two selection oper- ators:
. (period)
The operator . is called the direct member selector and it is used to directly access one of the structure’s members. Suppose that the object s is of struct type S. Then if m is a member identifier of type M declared in s, the expression
s.m // direct access to member m
is of type M, and represents the member object m in s.
The operator
// identical to (*ps).m
is of type M, and represents the member object m in s. The expression
For example:
struct mystruct {
int i; char str[10]; double d;
} s, *sptr = &s; |
|
. |
|
. |
|
. |
|
s.i = 3; | // assign to the i member of mystruct s |
sptr | // assign to the d member of mystruct s |
The expression s.m is an lvalue, provided that s is an lvalue and m is not an array type. The expression
|
| page |
MikroElektronika: Development tools - Books - Compilers | 77 | |
|