About something I read here(Type Safety paragraph): https://en.wikipedia.org/wiki/C_dynamic_memory_allocation
It says that in this code:
int *ptr, *ptr2;
ptr = malloc(10 * sizeof(*ptr)); /* without a cast */
ptr2 = (int *)malloc(10 * sizeof(*ptr)); /* with a cast */
an advantage of casting is "The cast allows for pre-1989 versions of malloc that originally returned a char *"
I don't understand, why is it important to cast it in order to be compatible with pre-1989 versions. In those versions, malloc returned char* and not void*, so malloc(10 * sizeof(*ptr)); will return a char pointer that contains the address of the allocated data, and then in ptr = malloc(10 * sizeof(*ptr)); ptr will point to the allocated data. the int * ptr will just point to the address pointed by the returned char *. So, the code without the casting should work on previous versions of C.