Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!stc!rmj From: rmj@tcom.stc.co.uk (Rhodri James) Newsgroups: comp.lang.c Subject: Re: Pointer Problems Message-ID: <1872@jura.tcom.stc.co.uk> Date: 20 Aug 90 17:47:00 GMT References: Reply-To: rmj@htc2.UUCP (Rhodri James) Organization: STC Telecomms, Harlow Technical Centre, Harlow Lines: 39 In article gh1r+@andrew.cmu.edu (Gaurang Hirpara) writes: > > > >I got a variety of solutions, but perhaps I didn't state the problem clearly. >The form ((StructName *)Something)->x=100 works. >However, the format I need is this type: > >TopLevel->Secondary->Something->x=100; > >i.e. I can't do the casting in the middle of the dereference. It won't let >me no matter which way I do it. Toplevel contains a pointer to >Secondary, which contains Something. Something initially points to a >void *. Am I missing something? Shouldn't ((StructName *)(TopLevel->Secondary->Something))->x=100; work? Or if all else fails you can hold the pointer to cast in a temporary variable of type void *, such as; void *Tempthing; . . Tempthing = TopLevel->Secondary->Something; ((StructName *)Tempthing)->x=100; Not very pleasant, I will admit, but it should work Rhodri Disclaimer: These ideas are mine, mine, all mine. The company doesn't know that I think, never mind what I think. -- * Windsinger * "Nothing is forgotten..." * rmj@islay.tcom.stc.co.uk * Mike Whitaker * or (occasionally) * "...except sometimes the words" * rmj10@phx.cam.ac.uk * Phil Allcock