Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!umich!ox.com!math.fu-berlin.de!fauern!unido!rwthinf!marvin.e17.physik.tu-muenchen.de!berg From: berg@marvin.e17.physik.tu-muenchen.de (Stephen R. van den Berg) Newsgroups: comp.lang.c Subject: Re: Pointer and integer addition Message-ID: <4205@rwthinf.UUCP> Date: 11 Apr 91 10:49:44 GMT References: <8334@umd5.umd.edu> <15631@smoke.brl.mil> Sender: news@rwthinf.UUCP Lines: 15 In article <15631@smoke.brl.mil> gwyn@smoke.brl.mil (Doug Gwyn) writes: >In article <8334@umd5.umd.edu> dzoey@terminus.umd.edu (Joe Herman) writes: >>fooptr = (char *) fooptr + fooptr->recsize; >This (almost) should have worked. You also need to convert back to >the proper pointer type before the assignment: > fooptr = (struct foo *) ((char *) fooptr + fooptr->recsize); No, not needed, the cast is implicit. -- Sincerely, berg@marvin.e17.physik.tu-muenchen.de Stephen R. van den Berg. "I code it in 5 min, optimize it in 90 min, because it's so well optimized: it runs in only 5 min. Actually, most of the time I optimize programs."