Name: Anonymous 2008-05-09 4:36
Hello /prog/. Imagine I have a struct:
struct foo {
enum entype { option1, option2 } *bar;
};
"bar" here stands for an array of enums, as you see.
Somewhere in my prog (after correctly allocating needed number of foo`s and bar`s) I have to access Nth bar in foo. I'm currently using this line:
*(enum entype*)(myfoo->bar + sizeof(enum entype)*N) = option1;
Well, it works, but I still think I'm doing it wrong. There must be an easier way, like myfoo->bar[N] or something.
struct foo {
enum entype { option1, option2 } *bar;
};
"bar" here stands for an array of enums, as you see.
Somewhere in my prog (after correctly allocating needed number of foo`s and bar`s) I have to access Nth bar in foo. I'm currently using this line:
*(enum entype*)(myfoo->bar + sizeof(enum entype)*N) = option1;
Well, it works, but I still think I'm doing it wrong. There must be an easier way, like myfoo->bar[N] or something.