I'm trying to delete a linked list and Its crashing when i get towards the end of the linked list.

void ZapList (NodePtr List)
{
  NodePtr Temp;

  while(List->Link != NULL)
  {
    Temp = List -> Link;              //set temp equal to the list pointer
    List = List -> Link-> Link;       //advance the pointer List
    delete Temp;                      //delete what Temp points to
  }
}

the error it is printing is

Unhandled exception at 0x008e1361 in OneSolution.exe: 0xC0000005: Access violation reading location 0x00000004.

I dont know how to fix it. It was working at one point then i did some other functions and now its not working. help??

Normally, the delete function should look like this :

void deleteList(Node * headNode)
{
    Node * temp = headNode;

   while(temp != null){
         temp = head->next;
         delete head;
         head = temp;
    }
}

I think that should be correct.