Mail Archives: djgpp/1997/03/03/11:30:04
>`malloc' returns void* while p can be of any pointer type. You are actually
>casting from (void*) to (char*).
>
>In C it is not a problem, the compiler does the conversion for you with or
>without warnings (depends on the compiler and warning level).
>
>In C++ it is a compilation error so you must explicitly cast from one
>pointer type to another (except when the target type is void*).
What you say is true, but in C++ we are meant to use new to dynamically
allocate memory space, in C
I believe it to be better practice to always cast your pointers esp. if
you use the likes of lint to ensure that
your code is extra safe
Rob Humphris
>
>
>Eyal.
>
>
- Raw text -