Is there anything wrong with the following functions?. Somehow, they are creating a segment fault.
struct processNode* create_node()
{
struct processNode* newNode = (struct processNode*)malloc(sizeof(struct processNode));
newNode->next = NULL;
return newNode;
}
struct processNode* append_node(struct processNode* list,struct processNode* newNode )
{
struct processNode* tracker= NULL;
tracker = list;
if(tracker == NULL)
{
tracker = newNode;
}
else
{
while(tracker->next != NULL)
{
tracker =tracker->next;
}
tracker->next = newNode;
tracker = tracker->next;
}
tracker->next=NULL;
tracker = list;
return tracker;
}
I am creating a shell in C and need to create a link list to parse the command lines from the user. In the second function, I intend to return a new list with the new appended pointer;