Let us examine the variable "boy" more closely. As stated above, each of the three elements of "boy" are simple variables and can be used anywhere in a C program where a variable of their type can be used.
For example, the "age" element is an integer variable and can therefore be used anywhere in a C program where it is legal to use an integer variable, in calculations, as a counter, in I/O operations, etc. The only problem we have is defining how to use the simple variable "age" which is a part of the compound variable "boy". We use both names with a
decimal point between them with the major name first. Thus "boy.age" is the complete variable name for the "age" field of "boy".
This construct can be used anywhere in a C program that it is desired to refer to this field. In fact, it is illegal to use the name "boy" or "age" alone because they are only partial definitions of the complete field. Alone, the names refer to nothing.
For example, the "age" element is an integer variable and can therefore be used anywhere in a C program where it is legal to use an integer variable, in calculations, as a counter, in I/O operations, etc. The only problem we have is defining how to use the simple variable "age" which is a part of the compound variable "boy". We use both names with a
decimal point between them with the major name first. Thus "boy.age" is the complete variable name for the "age" field of "boy".
This construct can be used anywhere in a C program that it is desired to refer to this field. In fact, it is illegal to use the name "boy" or "age" alone because they are only partial definitions of the complete field. Alone, the names refer to nothing.