How can I initialize this nested struct in C?
typedef struct _s0 {
int size;
double * elems;
}StructInner ;
typedef struct _s1 {
StructInner a, b, c, d, e;
long f;
char[16] s;
}StructOuter; StructOuter myvar = {/* what ? */ };
How can I initialize this nested struct in C?
typedef struct _s0 {
int size;
double * elems;
}StructInner ;
typedef struct _s1 {
StructInner a, b, c, d, e;
long f;
char[16] s;
}StructOuter; StructOuter myvar = {/* what ? */ };
To highlight struct labels in particular:
To initialize everything to 0 (of the right kind)
To initialize the members to a specific value
Edit
If you have a C99 compiler, you can also use "designated initializers", as in:
It seems a and b cannot be initialized in-place in plain C