G
gus gassmann
Hi,
I have a static struct, defined in a C header file as something like
typedef struct
SomeStruct {
char *name;
int kind;
int value;
}
and I need to supply (in C++) values to an array of this type. I
understand that I can set *static* values by
static SomeStruct
myStruct[] = {
{"name1", 1, 17},
{"name2", 7, 25},
{"name3", 3, 6},
{"name4", 0,117}
};
However, I need to set dynamic values along these lines (I know that the
code does not work):
static SomeStruct
myStruct[] = {
{name[0], kind[0], val[0]},
{name[1], kind[1], val[1]},
...
{name[n], kind[n], val[n]},
};
where both the values and the number of values are only known at
runtime. I cannot change the definition in the header file; I am not
even sure that what I want to do is possible. Any ideas?
Thanks
gus
I have a static struct, defined in a C header file as something like
typedef struct
SomeStruct {
char *name;
int kind;
int value;
}
and I need to supply (in C++) values to an array of this type. I
understand that I can set *static* values by
static SomeStruct
myStruct[] = {
{"name1", 1, 17},
{"name2", 7, 25},
{"name3", 3, 6},
{"name4", 0,117}
};
However, I need to set dynamic values along these lines (I know that the
code does not work):
static SomeStruct
myStruct[] = {
{name[0], kind[0], val[0]},
{name[1], kind[1], val[1]},
...
{name[n], kind[n], val[n]},
};
where both the values and the number of values are only known at
runtime. I cannot change the definition in the header file; I am not
even sure that what I want to do is possible. Any ideas?
Thanks
gus