To explain precisely what would occur with your proposed code (assuming you were able to correct it for successful compilation), the foo() function would create a pointer variable 'p' which you point at a piece of heap memory. You then dereference the pointer and place the value 5 in that heap memory location. Finally, you dereference and return the value at the heap memory location (which is 5). Upon exiting foo(), the heap memory is still allocated, but now can never again be accessed (that's bad). In main() the value 5 is copied into variable 'a' and printed out.