3 ms·
Can anyone explain how the last snippet works?
by GranPC 2y ago
Can anyone explain how the last snippet works?
- a12k 2y agoBasically they execute in order of array initialization, not index order, so it outputs hello cruel world rather than cruel world hello.
- andreyv 2y agoIt creates a compound literal [1] of type array of int, and initializes the specified array positions using designated initializers [2] with the results of calls to puts(). Using designated initializers without the = symbol is an obsolete extension. [1] https://gcc.gnu.org/onlinedocs/gcc/Compound-Literals.html https://gcc.gnu.org/onlinedocs/gcc/Compound-Literals.html [2] https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html