I am attempting to create a const structure in C but can’t seem to figure it out.
typedef struct sA{
char* fname;
char* lname;
} A;
To use as an Array:
A list[] = {{"david","smith"},{"john","smith"}};
However, if I have use a second struct:
typedef struct sB{
A inList[];
} B;
I want to define a const structure as:
B newList[] = {
{
{"david","smith"}
},
{
{"john","doe"}
{"joe","doe"}
}
};
len(newList[0].inList) is different from len(newList[1].inList). This can be built dynamically, but how would you build this into a const variable in C?
All the objects of a struct will always have same size. What you are trying do will result in different object of a struct having different sizes, which is not possible. So what you are trying to do is not correct