stack(automatic memory) implicitly handled by the compiler
void func() {
int x;
…
}
heap: explicitly handled by you, the programmer
void func() {
int *x = (int *) malloc(sizeof(int));
…
}
why put (int *) cast? (void *) and (int *) is physically the same, but for (void *), the compiler does not know the pointer arithmetic and dereferencing
man malloc
#include <stdlib.h>
…
void *malloc(size_t size);