increment casted void pointer -- ANSI?

Henry Spencer henry at zoo.toronto.edu
Wed Mar 13 03:34:30 AEST 1991


In article <166 at tdatirv.UUCP> sarima at tdatirv.UUCP (Stanley Friesen) writes:
>>There is no way to say "pretend this variable has a different type" in C.
>
>To pretend a variable has a different type utter the following magic
>incantations:
>
>b = *++ *(char **)&p;

Not quite.  This says "pretend that a sequence of bits, starting at the start
of `p', has a different type".  Whether this does the job depends on whether
you take "pretend" to mean "convert it and then convert it back" or "just
view the bits differently".  Consistency with casts would imply the former,
especially since all bets are off if you do the latter.  The original
inquirer clearly wanted the former.
-- 
"But this *is* the simplified version   | Henry Spencer @ U of Toronto Zoology
for the general public."     -S. Harris |  henry at zoo.toronto.edu  utzoo!henry



More information about the Comp.lang.c mailing list