Pointer and integer addition

Stephen R. van den Berg berg at marvin.e17.physik.tu-muenchen.de
Thu Apr 11 20:49:44 AEST 1991


In article <15631 at smoke.brl.mil> gwyn at smoke.brl.mil (Doug Gwyn) writes:
>In article <8334 at umd5.umd.edu> dzoey at 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 at 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."



More information about the Comp.lang.c mailing list