
Help with Struct Syntax
// The syntax for initializing a two dimensional integer array is:
int array[3][3] = {
{1, 2, 3},
{2, 2, 3},
{3, 3, 3}
};
// The syntax for initializing a structure is:
struct structure_name
{
char word[20];
int number;
};
struct structure_name instance = { "Hello World!", 8 };
// But how do you initialize x[2] y[2] within a nested structure?
// Thanks to anyone who helps.
// ? ? ? ? ? ?
typedef struct inside_structure
{
int x[2];
int y[2];
} inside_instance1, inside_instance2;
struct outside_structure
{
inside_structure inside_instance1;
inside_structure inside_instance2;
};
struct outside_structure outside_instance1 = {
{inside_instance1 = { { 1, 2 }, { 1, 2 } }; },
{inside_instance2 = { { 1, 2 }, { 1, 2 } }; }
};
struct outside_structure outside_instance2 = {
{inside_instance1 = { { 1, 2 }, { 1, 2 } }; },
{inside_instance2 = { { 1, 2 }, { 1, 2 } }; }
};

This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement