I am struggling, C peeps.
I have:
struct thing {
int i;
};
struct stuff {
int i;
thing *t;
};
stuff **pst;
There are many stuffs (in pst on the heap) each of which have many things which are allocated on the heap.
I know which stuff I want to access and which thing in the stuff. x is the element of thing I want.
So what I want to say is
something=*pst->(t+x)->i;
The "(" is a syntax error which it shouldn't bloody well be, but it is.
Can I access that without something like
thing *t;
t=*pst->t+x;
something=t->i;
No, didn't think so.
3 comments:
Can't you access via array syntax?
*pst->t[y]->i;
with y adjusted to an array offset from x? (x/sizeof(t)) perhaps?
Assuming you want pst to be a pointer to an array of many pointers to stuff structures, then the following should work.
struct stuff *somestuff = *pst[x];
struct thing *something = somestuff->t;
Correction
struct stuff *somestuff = pst[x];
struct thing *something = somestuff->t;
Post a Comment