www.thecareerplus.com
The CareerPlus
Home Technical Resources Programming Arrays and Pointers
Wednesday 08th September 2010
 
 
Is the cast to malloc() required at all?

Discuss it!          


Before ANSI C introduced the void * generic pointer, these casts were required because
older compilers used to return a char pointer.
int *myarray; myarray = (int *)malloc(no_of_elements * sizeof(int)); But, under ANSI Standard C, these casts are no longer necessary as a void pointer
can be assigned to any pointer. These casts are still required with C++, however.

Discuss it!          

CrackTheIntervew.NET
Advertisement
 
Top! Top!