You keep a pointer to the first node. Then, you go from node to node until you reach the end node, whose "next" pointer is NULL. That's all there is to it.
Here's some sample C++ source that may help.
PHP Code:
//A node is an individual "link" in a linked list
struct node
{
int x;
node * next;
};
node * beginning = new node;
node * current = beginning;
int n; //Will temporarily store numbers that we get with cin
cout << "Enter numbers. Enter a non-numeric character to finish.\n";
while(cin >> n)
{
current->x = n; //Put data in node
current->next = new node; //Create new node
current = current->next; //Move to next (new) node
current->next = NULL; //Make new node last node
}
cout << "We will now display the numbers you input\n";
current = beginning; //Start at the beginning
while(current != NULL) //If we haven't moved past the last node
{
cout >> current->x;
current = current->next; //move to next node
}
cout << "Done. Now we'll delete.\n";
node * next; //Temporarily holds next
current = beginning; //Start at the beginning
while(current != NULL) //If we haven't moved past the last node
{
next = current->next; //hold next so we have it when we delete current
delete current; //delete current node
current = next; //move to next node
}
cout << "And now we've cleaned up and we're done.\n";