I took a look at the standard and noticed that malloc does return void *. But in the examples, no casting is done.
A comment to the code:
Code:
/* allocate memory for string */
if ((str = (char *) malloc (10)) == NULL)
{
printf("Not enough memory to allocate buffer\n");
#ifdef SHIRO_CODE
/* I would use a return instead of exit, mainly since
main is of type int, so it should return an int when
exiting. This int can be an errorvalue. */
return ERROR_VALUE;
#else
exit(1); /* terminate program if out of memory */
#endif
}