Now, let's see the semantics of malloc. Here we have a small example of code which uses malloc. It does not really accomplish anything, but we'll let you see what malloc does. Our first statement just declares an int star p which is uninitialized. The next statement is an assignment statement. So, you will follow the same rules you always do. Find the box named by the left-hand side. In this case, p. And evaluate the right hand side expression to get a new value to put into that box. In this case, that expression is a call to malloc which will allocate memory. Allocating memory, means that you're going to draw a new box. This new box will be in the heap, not in any stack frame. Unlike variables which reside in stack frames, this box that you will create in the heap does not have its own name. To see what the new box looks like, you need to look at the argument passed to malloc. Here, it is six times the size of star p. Which means, it will be an array of six elements. As p as an inch pointer, those elements will be ints. So, let's draw that box. Note that each element inside the array is uninitialized. Whenever you create new boxes, they are uninitialized until you explicitly place a value in them. The return value of malloc is a pointer to this newly allocated memory. So now, you are ready to finish the assignment statement, placing the return value of malloc, which is the value of the function call into p's box. Now, let's look at what happens later when the function returns. The frame for the current function is in the stack. So, it will be destroyed automatically when the function returns. This behavior is exactly what you are used to from prior lessons. However, the memory that was allocated by malloc is in the heap. This memory will not automatically be freed when the function returns. So, when you execute the return statement, you will destroy the frame but not change anything in the heap. Anything allocated in the heap will continue to exist until you explicitly free it. Which allows you to allocate memory inside a function, and return a valid pointer to use it in other functions.