Mail Archives: djgpp/1997/03/03/04:50:35
Paul Derbyshire wrote:
> Also: no typecast is needed to assign the result of a malloc or calloc to
> a pointer.
>
> int *bunch_of_ints;
> bunch_of_ints=malloc (3000*sizeof(int));
>
> will work just as well as
>
> int *bunch_of_ints;
> bunch_of_ints=(int *)malloc (3000*sizeof(int));
>
> and is more readable.
It will work, but it's not strictly-conforming ANSI C. Converting to a
void * to any other pointer type requires an explicit typecast.
--
Erik Max Francis, &tSftDotIotE / email: max AT alcyone DOT com
Alcyone Systems / web: http://www.alcyone.com/max/
San Jose, California, United States / icbm: 37 20 07 N 121 53 38 W
\
"I am become death, / destroyer of worlds."
/ J. Robert Oppenheimer (quoting legend)
- Raw text -