English
Language : 

CC78K0S Datasheet, PDF (133/520 Pages) NEC – C Compiler Ver.1.30 or Later Language
CHAPTER 7 STRUCTURES AND UNIONS
[Example of bit field declaration]
struct bf_tag{
unsigned int a:2;
unsigned int b:3;
unsigned int c:1;
}bit_field;
bit field
(3) Arrays and pointers
Structure variables may also be declared as an array or referenced using a pointer.
[Structure arrays]
An array of structures is declared in the same ways as other objects.
struct data{
char name[12];
char addr[50];
char tel[12];
};
struct data no[5];
[Structure pointers]
A pointer to a structure has the characteristics of the structure indicated by the pointer. In other words, if a
structure pointer is incremented, adding the size of the structure to the pointer points to the next structure.
In the following example, “dt_p” is a pointer to the value of “struct data” type. Here, if the pointer “dt_p” is
incremented, the pointer becomes the same value as “&no[1]”.
struct data no[5];
struct data *dt_p=no;
(4) How to refer to structure members
A structure member (or structure element) may be referenced in two ways: one by using a structure variable and
the other by using a pointer to a variable.
[Reference by using a structure variable]
The . (dot) operator is used for referring to a structure member by using a structure variable.
struct data{
char name[12];
char addr[50];
char tel[12];
}no[5]={"NAME","ADDR","TEL"};*data_ptr=no;
void main(){
char c ;
c=no[0].name[1];
}
User’s Manual U14872EJ1V0UM
133