December 2012
Beginner
552 pages
12h 58m
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, 2011, you can use this statement:
struct date today = { 7, 2, 2011 } ;
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
struct date today = { .month ...
Read now
Unlock full access