0

When I allocate memory for a structure in C using the malloc function, why don't I have to cast the function since its returning type is void* and not the structure I want? So why this:

Str *str = malloc(sizeof(Str));

and not this:

Str *str = (Str*)malloc(sizeof(Str));

?

Piddy
  • 59
  • 5

0 Answers0