Path: utzoo!attcan!uunet!cs.utexas.edu!wuarchive!emory!mephisto!prism!cc100aa From: cc100aa@prism.gatech.EDU (Ray Spalding) Newsgroups: comp.lang.c Subject: Re: Pointer Problems Message-ID: <12592@hydra.gatech.EDU> Date: 15 Aug 90 15:27:14 GMT References: <8aliOrS00WBMI1UVYX@andrew.cmu.edu> Organization: Georgia Institute of Technology Lines: 21 In article <8aliOrS00WBMI1UVYX@andrew.cmu.edu> gh1r+@andrew.cmu.edu (Gaurang Hirpara) writes: >Ok. I have a struct, call it idiot, with some elements in it, nothing unusual. > >Now, I have another struct, which contains in it a generic >pointer (i.e. Ptr ). >How can I make point to idiot, AND be able to access the >resulting pointer as a pointer to struct. My main problem is that even >if I do manage to get them to point to the same place (which is a problem >all by itself), I can't access the internal members of the struct. You should be able to use a cast, e.g: x = ((struct idiot *)pointername)->element; Note that "Ptr" is not part of the C language; it's probably typedef'd somewhere to "void *" or, to accommodate older implementations, "char *". -- Ray Spalding, Technical Services, Office of Information Technology Georgia Institute of Technology, Atlanta Georgia, 30332-0275 uucp: ...!{allegra,amd,hplabs,ut-ngp}!gatech!prism!cc100aa Internet: cc100aa@prism.gatech.edu