C
Captain Pugwash
Hi!
What's the correct way to initialise nested structures?
I have, for example, the following:
struct staff_member
{
char *forename;
char *surname;
};
struct department
{
char *name;
struct staff_member *staff;
};
struct department departments[] =
{
{ "development", { { "Alex Buell" } } },
{ "marketing", { { "Sales". "Droid 1" }, { "Sales", "Droid 2" } } },
};
This won't compile correctly, What is the correct way to do this?
Thanks
What's the correct way to initialise nested structures?
I have, for example, the following:
struct staff_member
{
char *forename;
char *surname;
};
struct department
{
char *name;
struct staff_member *staff;
};
struct department departments[] =
{
{ "development", { { "Alex Buell" } } },
{ "marketing", { { "Sales". "Droid 1" }, { "Sales", "Droid 2" } } },
};
This won't compile correctly, What is the correct way to do this?
Thanks