ZekeDragon said:
You're trying to call a variable name as a variable in itself, and no, you can't do that. It's very easy to do this:
est[1].a = 0;
But you can't try and use the value of a variable as the name of another variable, it's simply impossible. I'm not even sure why you'd want to try and do this, is there some reason for it?
Mwoahaha wanna bet? :rules: Well, technically you are right, but this might help you suricata:
typedef struct {
unsigned short a, b, c, d, e, f, g, h;
}est_;
est_ est[512];
int i, a;
unsigned short* p_est[512][8];
for(a = 0; a < 512; ++a)
{
for(i = 0; i < 8; ++i)
{
switch(i)
{
case 0:
p_est[a][i] = &est[a].a;
break;
case 1:
p_est[a][i] = &est[a].b;
break;
case 2:
p_est[a][i] = &est[a].c;
break;
case 3:
p_est[a][i] = &est[a].d;
break;
case 4:
p_est[a][i] = &est[a].e;
break;
case 5:
p_est[a][i] = &est[a].f;
break;
case 6:
p_est[a][i] = &est[a].g;
break;
case 7:
p_est[a][i] = &est[a].h;
break;
}
}
}
As you can see we now have a two dimensional array of pointers.
To access for example est[23].g we would do:
*p_est[23][6] = 5; /* Set est[23].g to 5 */
So to fill every est (all 512) a,b,c,d,e,f,g,h with fives you could do:
for(a = 0; a < 512; ++a)
for(i = 0; i < 8; ++i)
*p_est[a][i] = 5;