Vote count:
0
I am working on a homework assignment about linked lists. One of the functions I need to write is to add a node to the back of the linked list. The code I wrote in an attempt to do this is as follows:
void add_back(struct Node **list, int value)
{
/* Variable Declarations */
struct Node *pNewNode; /* A pointer to the new node we want to add */
struct Node *pTemp; /* A temp pointer for walking through the list */
/* Allocate space for our new node and initialize its member variables */
pNewNode = malloc(sizeof(struct Node));
pNewNode->number = value;
pNewNode->next = NULL;
/* Sets pTemp to the head pointer, so we don't mess with it */
pTemp = *list;
/* While we're not at the end of the list */
while(pTemp->next != NULL)
{
/* Go to the next entry in the list */
pTemp = pTemp->next;
}
/* Have the previous end of the list point at the new end of the list */
pTemp->next = pNewNode;
}
The specific error message I'm getting is "0 [main] list 3384 cygwin_exception::open_stackdumpfile: Dumping stack trace to list.exe.stackdump"
I tried looking at the stackdump file to try and gain some insight, but I'm not sure how to interpret it.
asked 1 min ago
Stackdump Error working with Linked Lists.
Aucun commentaire:
Enregistrer un commentaire