I try it :
#include #include void foo(int* x) { x = (int *)malloc(sizeof(int)); *x = 5; } int main() { int a;
Pointer x is already initialized in formal arguments, malloc will create x pointing to another memory location.
x
malloc
void foo(int* x) { /* x = (int *)malloc(sizeof(int)); */ *x = 5; }
Please look at Acme's answer for very good diagrammatic representation.