Question 7.7

Why does some code carefully cast the values returned by malloc to the pointer type being allocated?


Before ANSI/ISO Standard C introduced the void * generic pointer type, these casts were typically required to silence warnings (and perhaps induce conversions) when assigning between incompatible pointer types. (Under ANSI/ISO Standard C, these casts are no longer necessary.)

References: H&S Sec. 16.1 pp. 386-7


Read sequentially: prev next up top


This page by Steve Summit // Copyright 1995 // mail feedback