Operations on pointers to void.

Karl Heuer karl at haddock.ima.isc.com
Thu Aug 16 09:02:04 AEST 1990


In article <174 at srchtec.UUCP> johnb at srchtec.UUCP (John Baldwin) writes:
>	void *myptr; ... *((char *)&myptr) += 3;

The cast should be to `char **', and it won't work if `myptr' is a register.
I think `myptr = (void *)((char *)myptr + 3);' is better, or (if all the
operations are on the same datatype anyway) just make a `char *' copy of the
original pointer and use it exclusively.

Karl W. Z. Heuer (karl at kelp.ima.isc.com or ima!kelp!karl), The Walking Lint



More information about the Comp.lang.c mailing list