I have following struct:
typedef struct my_struct {
int a;
int b;
int *c;
} my_struct;
is:
my_struct n = (my_st
Is
my_struct n = (my_struct) { .b = 3 };equivalent tomy_struct n = (my_struct) { .a = 0, .b = 3, .c = NULL };?
Yes. A compound literal may fail to provide full initialization, in which case any unimitialized members initialize to zero (NULL is case of pointer member) by default.
What about
my_struct n = (my_struct) { .b = 3, 0 };?
Member b and c will be initialized to 3 and 0 respectively while a will be initialized to 0 by default.