I am trying to write a struct in c that stores data in a linked array like this:
typedef struct
{
u8 num;
struct value* next;
}value;
value arr[4] = {
{.num = 0, .next = (value[]){
(value){.num = 0, .next = NULL},
(value){.num = 1, .next = NULL},
(value){.num = 31, .next = NULL}
}},
{.num = 1, .next = NULL},
{.num = 2, .next = NULL},
{.num = 31, .next = NULL}
};
Instead of nulls there will be linked array up to 6 hierarchy levels.
How can I do that in C? What am I doing wrong?
Btw, the entire structure should be const
so I need to initialize it with values and never touch it again during runtime.
And if you have a method to do that in c++ I can also work with it.