Mail Archives: djgpp/1998/01/27/15:33:23
Vic wrote:
> Hello. I'd like to be able to do something like this:
> I have a struct foo (int x,y,z) and a void* bar=&foo;
> So bar holds the adress of foo. I know that at the beginning of the
> struct lies the first member. so why can't I just say *bar=55 or
> something?
> I'd like to be able to access any member of a struct using a pointer.
> Like, if I want to access the second member, I add 4(or whatever) to
> the
> pointer and write the value to that adress. How could I do that?
> HELP!!
> TIA,
> --
> --> http://www.cam.org/~tudor <--
With -> you can acces any type of struct from a void pointer;
Well, you just need to acces to variables in the struct in the next way:
bar->x=55;
Jordi Pérez Bou, jordimln AT jet DOT es
alternative e-mail: e6707357 AT est DOT upc DOT es
/**********************************************(Excuse my english)
- Raw text -