I create a new element of a struct inside a function and then send a pointer to that new element into another function where it sets that equal to the head and links the previous link of the head to the link of the new element. When it comes back from the function where it does that the head is set back to NULL though.. can any of you tell me why???
Code:
// Function Definitions
ListType *InitializeList(...);
void AddToList(ListType * New, ListType * Head);
// Functions Call Sets back to Zero after returning from here
AddToList(InitializeList(name, size, Bubble, Selection, Insertion), Head)
// Initializes the list, ... is omitted code for putting the data into the list
ListType *InitializeList(...)
{
ListType * This = new ListType;
...
This->Next = NULL;
return This;
}
// Adds a new element to the list
void AddToList(ListType * New, ListType * Head)
{
ListType * temp = Head;
Head = New;
Head->Next = temp;
}
if someone can help me out here i would be very grateful =]