Casting the lvalue

Scot Mcintosh psm at manta.NOSC.MIL
Tue Mar 6 11:45:19 AEST 1990


The following seems to be illegal (at least under Microsoft C
version 5.1):
(int)array[1] = 5;

while this appears to be ok:
*(int *)&array[1] = 5;

Question: why is the first form illegal, and is there
a more 'elegant' way than the second form to accomplish
the same thing?

-- 
----
Scot McIntosh
Internet: psm at helios.nosc.mil
UUCP:     {ihnp4,akgua,decvax,decwest,ucbvax}!sdscvax!nosc!psm



More information about the Comp.lang.c mailing list