This creates and initializes a two-dimensional array of structures, with each row containing three. Note that you haven't provided an initializer for the array[1][2]
, which in this case means its contents is undefined.
struct foo {
const char *x;
int y;
};
int main()
{
struct foo array[][3] = {
{
{ "foo", 2 },
{ "bar", 5 },
{ "baz", -1 },
},
{
{ "moo", 44 },
{ "goo", 200 },
}
};
return 0;
}
EDIT: Made x pointer to const string. Try to make your examples close to your real code.
Matthew Flaschen
2010-04-26 21:13:44