#include<iostream>
using namespace std;
//Defines the node
struct node
{
//An integer
int value;
//A node pointer
node *next;
};
int main(void)
{
//Declares the first, unchanging node
node *root;
//Declares the "conductor" node which will traverse down the list
node *conductor;
//The first node, root, points to a new node
root = new node;
//The fith node along the line, has it's pointer, *next, set equal to a null pointer
root->next->next->next->next = 0;
//Sets the value of the nodes
root->value=1;
root->next->value=2;
root->next->next->value=3;
root->next->next->next->value=4;
//Conductor is set to point to root
conductor=root;
//Prints all the values in the list
while(conductor!=NULL)
{
cout<<conductor->value<<" ";
conductor=conductor->next;
}
cout<<"\n";
cin.get();
return 0;
}
The ProblemEverything works fine untill the last cin.get();
when an error comes up on windows vista saying "linked_lists.exe has stopped working. Windows is checking for a solution to the problem."
Thanks for your help
Ratchet
Edited by WingedPanther, 15 July 2008 - 07:58 AM.
add code tags


Sign In
Create Account


Back to top









