type cast in initializer

Doug Gwyn gwyn at brl-smoke.ARPA
Fri Feb 7 09:30:45 AEST 1986


>> >	int	x = 0;
>> >	char	*ptr = (char *) &x;
>> 
>>     In any case, I'm not sure why you'd want to do what your example does,
>> since the cast here is a no-op.  
>
>An int pointer does not necessarily have the same format as a char pointer.
>Consider a word addressible machine on which the char's are packed into the
>words.

But, the = forces the same type coercion as the type cast.
Writing the cast explicitly is good style, however.
I don't see why the fellow wants to do what he's doing
quite apart from the question of how to express it..



More information about the Comp.lang.c mailing list