would love for some help with understanding the difference between these two lines:
int(*p)[20] = (int(*)[20]) malloc(sizeof(int) * 20);
int* y = (int*)malloc(sizeof(int) * 20);
if I do:
int * tmp = p;
OR
int * tmp = y;
I get the address of the first element in the array/memory allocated.
Would love for some more thorough understanding of what the difference is and when would I use each one of them?
Addition to the question:
is this casting legal? please explain why and if it is legal, what is tmp equal to?:
int(*p)[20] = (int(*)[20]) malloc(sizeof(int) * 20);
int * tmp = (int*) p;
Thanks to anyone that contributes!
Sincerely,
Roe :)