Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

but one can use designators to initialize array elements in a non-contiguous fashion. section 6.7.8 "initialization":

EXAMPLE 12 Space can be "allocated" from both ends of an array by using a single designator:

Code Block
int a[MAX] = {
  1, 3, 5, 7, 9, [MAX-5] = 8, 6, 4, 2, 0
};

In the above, if MAX is greater than ten, there will be some zero-valued elements in the middle; if it is less than ten, some of the values provided by the first five initializers will be overridden by the second five.

...