Programming in C

(Barry) #1

190 Chapter 9 Working with Structures


Figure 9.3 The array months.

Structure Variants


You do have some flexibility in defining a structure. First, it is valid to declare a variable
to be of a particular structure type at the same time that the structure is defined.This is
done simply by including the variable name (or names) before the terminating semi-
colon of the structure definition. For example, the statement

31

'a'
'n'

'F'

'M'

[0]
[1]
[2]

.name

'J'

28

'e'
'b'
31

'a'
'r'

'A'
'p'

30

[0]
[1]
[2]

.name

[0]
[1]
[2]

.name

[0]
[1]
[2]

.name

numberOfDays

numberOfDays

numberOfDays

numberOfDays

months[0]

months[1]

months[2]

months[3]

31

'e'
'c'

[0]
[1]
[2]

.name

'D'

numberOfDays

months[11]

'r'
Free download pdf