Hi everyone,
I'm studying for my final exam and I am stuck on a review question.

The question is as follows:

Consider this code fragment and answer the questions, which follow.

NODE *p1, *p2,*p3;
NODE *p, *pFirst, *pNew, *pTemp;

Question:
Write the code to allocate memory for nodes at p1, p2, and p3. Do not declare any new variables. Assume that your code will appear after the above fragment, and write only the necessary statements.

This is what I have come up with. Let me know if I am right or where I went wrong.

pFirst = NULL;


pNew = new NODE;
pNew->link = NULL;
if (pFirst == NULL)
{
pFirst = pNew;
pTemp = pNew;
}
else
{
pTemp->link = pNew;
pTemp = pNode;
}