For the C code below, compare the defintions of the int pointers a and b;
#include
#include
int main()
{
int *a=malloc(s
void
, so malloc()
returned a char *
. Now, you needed to do the cast. Consequently the design pattern of casting malloc()
developed and influenced all the people who wrote the next set of code, and people are stilling reading those code bodies today and carrying the pattern forward. But C89 had void and so it's time to streamline the code.