Hi,
Say the node has data structure:
and "node" is declared asCode:struct tdnode { char *task; char *notes; TDnode *next; };
TDnode *node = head; (head of list)
Now I have to scan through each and every node in the list. The nodes inside this list are called "nodes", correct? If so, how do you copy the node "node" to a node called "tmp"?
1) tmp = node; will not "work" because all that is saying is that "tmp" points to the same node that "node" is pointing to. So if I change the data inside the "node" node then *tmp returns the changed "node" instead of the original "node" before change.
I was thinking of:
Basically from the above, what I'm trying to do is copy every node called "node" into another node called "tmp" (I know that "node" and "tmp" are pointers, but I hope at the moment I can' think of a more concise way to address my problem).Code:while( ( node != NULL ) ) { tmp->task = node->task; tmp->notes = node->notes; node = node->next; }
Pardon my confusing question.
Any help'll be appreciated.