I'm doing an exercise where I'm allocating my array data to the heap instead of the stack.
so I changed my code from:
int array[n];
to
int *array = (int*) malloc(n*sizeof(int));
When I'm looking at my friends code that got the same exercise, they wrote int *array = malloc(sizeof(int)*n);
so,
what is the difference between int *array = (int*) malloc(n*sizeof(int));
and int *array = malloc(sizeof(int)*n);
?