View Single Post
Old 01-19-2004, 08:18 AM   #9
Rhuarc
Member
 
Join Date: Jul 2003
Posts: 50
Rhuarc is on a distinguished road
This is incorrect.  malloc() returns a void*, which, if your compiler is typecasting for you, your compiler is broken.

 You must typecast the result of malloc() to the type that you require.

[code]  char* p  = (char*)malloc( 10 * sizeof(char) ); [/quote]

 will compile,

[code] char *p = malloc( 10 * sizeof(char) );  [/quote]

 will not, not even in vc++.
Rhuarc is offline   Reply With Quote