I'm trying to make a doublly linked list then uses an addbefore and addafter function the return a pointer to a node. It works when I don't use the function but messes up when I use them
Here is my code some of my code
void insert(ListNodePtr *sPtr, char *string){
some code...( *sPtr is my main node)
.
.
.
while(currentPtr-%26gt;prevPtr != NULL %26amp;%26amp; (strcmp(string, currentPtr-%26gt;word) %26lt;= 0)){
currentPtr = currentPtr-%26gt;prevPtr;
}
*sPtr = addAfter(currentPtr, string); //ADDING AFTER
}
.
.
.
}
Doubly Linked List???
The part of insert() that you quoted doesn't initialize currentPtr, but maybe that gets done in the elided section. Presumably you want to set currentPtr = sPtr.
In addAfter(), I assume you want to copy the passed string into the new node, but that doesn't appear to happen, unless it's buried in the part that Yahoo turned into "...".
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment