December 2013
Beginner
576 pages
16h 4m
English
Initializing structures is similar to initializing arrays; the elements are simply listed inside a pair of braces, with a comma separating each element.
To initialize the date structure variable today to July 2, 2014, you can use this statement:
struct date today = { 7, 2, 2014 } ;
As with the initialization of an array, fewer values can be listed than the structure contains. So the statement
struct date today = { 7 } ;
sets today.month to 7 but gives no initial value to today.day or today.year. In such a case, their default initial values are undefined.
Specific members can be designated for initialization in any order with the notation
.member = value
in the initialization list, as in ...
Read now
Unlock full access