Mukesh Chauhan

Just another WordPress.com weblog

Casting malloc

Originally, the C language did not enjoy the void pointer. In those dark ages the char pointer was used as a generic pointer, so the definition of malloc looked something like this:

char *malloc(size)
int size;

Of course, this tended to cause problems when trying to assign a char pointer to, say, a double pointer. Because of this a cast was required:
Continue reading

May 30, 2010 Posted by | Programming | Leave a comment