
Structures and Unions
→
Structures
•
Syntax
struct
struct-name
{
data-type member1;
data-type member2;
...
data-type membern;
} [
variable-list];
•
Description
A structure is a collection of one or more variables, possibly of different
types, grouped together under a single name for convenient handling.
Structures may be copied and assigned to, passed to functions and
returned by functions. C allows bit fields. Nested structures are also
allowed.
The reserved word struct indicates a structure is to be defined while
struct-name is the name of the structure. Within the structure, data-
type is one of the valid data types. Members within the structure may
have different data types. The variable-list declares variables of the
type struct-name. Each item in the structure is refered to as a member.
After defining a structure, other variables of the same type are declared
with the following syntax:
struct
struct-name variable-list;
To access a member of a structure, specify the name of the variable and
the name of member separated by a period. The syntax is
svariable
.
member1
where svariable is the variable of structure type and member1 is a
member of the structure. A structure member can have a data type with
a previously defined structure. This is referred to as a nested structure.
•
Example
struct person_id
{
char id_num[6];
char name[3];
unsigned long birth_date;
} mark;
Chapter 9 Holtek C Language
101
Содержание HT-IDE
Страница 11: ...P a r t I Integrated Development Environment Part I Integrated Development Environment 1 ...
Страница 12: ...HT IDE User s Guide 2 ...
Страница 20: ...Fig 1 6 Fig 1 7 HT IDE User s Guide 10 ...
Страница 24: ...HT IDE User s Guide 14 ...
Страница 70: ...HT IDE User s Guide 60 ...
Страница 76: ...HT IDE User s Guide 66 ...
Страница 92: ...HT IDE User s Guide 82 ...
Страница 93: ...P a r t I I Development Language and Tools Part II Development Language and Tools 83 ...
Страница 94: ...HT IDE User s Guide 84 ...
Страница 148: ...HT IDE User s Guide 138 ...
Страница 150: ...Fig 12 1 Fig 12 2 HT IDE User s Guide 140 ...
Страница 154: ...HT IDE User s Guide 144 ...
Страница 192: ...HT IDE User s Guide 182 ...
Страница 194: ...HT IDE User s Guide 184 ...
Страница 218: ...HT IDE User s Guide 208 ...
Страница 235: ...P a r t V Appendix Part V Appendix 225 ...
Страница 236: ...HT IDE User s Guide 226 ...
Страница 250: ...HT IDE User s Guide 240 ...