Tutorial by Examples

In the absence of explicit initialization, external and static variables are guaranteed to be initialized to zero; automatic variables (including register variables) have indeterminate1 (i.e., garbage) initial values. Scalar variables may be initialized when they are defined by following the name w...
Structures and arrays of structures can be initialized by a series of values enclosed in braces, one value per member of the structure. struct Date { int year; int month; int day; }; struct Date us_independence_day = { 1776, 7, 4 }; struct Date uk_battles[] = { { 1066, ...
C99 C99 introduced the concept of designated initializers. These allow you to specify which elements of an array, structure or union are to be initialized by the values following. Designated initializers for array elements For a simple type like plain int: int array[] = { [4] = 29, [5] = 31, [1...

Page 1 of 1