[Dev-C++] adding nodes to the end of linked list
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: chromatonus 7. <chr...@ho...> - 2001-11-11 21:54:41
|
hi, my add_back function only adds one number to the list, it has to add
nodes until i display the list (not included) , problem with the else
section and probably more,
thanks!!
struct node
{
int data;
node *next;
};
node add_back(node *&list, int info)
{
node *skip = new node;
node *tail = new node;
if (list == NULL)
{
tail -> data = info;
tail -> next = NULL;
list = tail;
skip = tail;
delete tail; // probably wrong...
}
else
{
tail -> data = info;
tail -> next = NULL;
skip -> next = tail;
skip = tail;
delete tail;
}
}
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
|