Allocate memory before using the pointer. If you don't allocate memory *point = 12
is undefined behavior.
int *fun()
{
int *point = malloc(sizeof *point); /* Mandatory. */
*point=12;
return point;
}
Also your printf
is wrong. You need to dereference (*
) the pointer.
printf("%d", *ptr);
^