Hehe...well it is probably doable, and I don't really have any sourcecode atm, but I can write some pseudocode that hopefully will explain it:
int x,y,z;
x = number_range(1, 10);
switch( x )
{
default:
struct_to_be_us ed == struct_default
case 1:
struct_to_be_us ed == struct_1
case 2:
struct_to_be_us ed == struct_2
etc.etc
}
/*After we have found the correct struct, depending on x we can finally use that*/
y = struct_to_be_us ed[something].integerY;
z = struct_to_be_us ed[something].integerZ;
..... more code using the struct we found....
Now of course this could be done as:
switch( x )
{
default:
y = struct_default[something].integerY;
z = struct_default[something].integerZ;
..... more code using struct_default. ...
case 1:
y = struct_1[something].integerY;
z = struct_1[something].integerZ;
..... more code using struct_1....
case 2:
etc etc..
But this gives quite a lot of code compared to, somehow, just make a "struct_to_be_u sed" and then have that point to the proper struct via the switch statement, thus only having to have the switch statement, and then the block of code ones instead of inserted into each of the cases in the switch statement.
I hope that made a bit of sense.
Why not set the pointer in the switch and then do all the "repetitive " stuff (as you state in your first post) after the switch? What's the "repetitive " stuff?
Well... that is basically what I want to do... I just don't know how to make a pointer point to a specific struct. Could you give an example or perhaps a reference ? Pointers aren't my best friends sadly.