i have the following struct:
struct node {
char *data;
struct node *next;
};
I want to initialize it with some already known values.
E.g:
struct node {
char *data;
struct node *next;
} *root = &(struct node){"data1", &(struct node){"data2", NULL}};
It's possible to get the address of the struct that contains "data2"? or to assign root to the struct that contains "data2"?
Edit:
I want to make the following at compile time with compound literals:
struct node *b = &(struct node){"data2", NULL};
struct node *a = &(struct node){"data1", b};
a = b;
Edit2:
something like that:
struct node {
char *data;
struct node *next;
};
struct node *tmp, *root = &(struct node){"data1", tmp = &(struct node){"data2", root}};
root = tmp;
but i do not want tmp to exist at run time