#include typedef struct { int a; int b; } bar; typedef struct { int a; int b; bar c; int d; bar e; } foo; void test_a(foo *f) { *f = (foo) { .a = 1, .b = 2, .c = (bar) { .a = 3, .b = 4, }, .d = 5, .e = (bar) { .a = 6, .b = 7, }, }; } void test_b(foo *f) { *f = (foo) { .a = 1, .b = 2, .c = (bar) { 3, 4, }, .d = 5, .e = (bar) { 6, 7, }, }; } void test_c(foo *f) { *f = (foo) { 1, 2, (bar) { .a = 3, .b = 4, }, 5, (bar) { .a = 6, .b = 7, }, }; } int main(int argc, char **argv) { foo f; test_a(&f); printf("%d %d %d %d %d %d %d\n",f.a, f.b, f.c.a, f.c.b, f.d, f.e.a, f.e.b); test_b(&f); printf("%d %d %d %d %d %d %d\n",f.a, f.b, f.c.a, f.c.b, f.d, f.e.a, f.e.b); test_c(&f); printf("%d %d %d %d %d %d %d\n",f.a, f.b, f.c.a, f.c.b, f.d, f.e.a, f.e.b); return 0; }