#include <iostream.h>
struct node
{
node* next;
int num;
};
node* head;
node* tail = head;
void NewNode(int number)
{
tail->next = new node;
tail = tail->next;
tail->num = number;
}
int main()
{
for(int x; x <= 10; x++)
NewNode(x);
return 0;
}
Now it compiles fine but when I run it it makes a runtime error stating that List2(the name of the program) has caused an error. Now I comment out the for() and change the x in NewNode to 5 and still get the error. I amlost sure its my tail pointer, but looking at an example it looks exactly like this. If it could be my OS Im usuing Windows ME
Jeff D
Suffered seven plagues, but refused to let the slaves go free. ~ Ross Atherton
Linked List question
Ok ive been trying to learn linked lists for a little while. when I think I got it I try to make one without looking at a book nor tutorial. So I make this:
Suffered seven plagues, but refused to let the slaves go free. ~ Ross Atherton
DOH!!!!!!!!!!
Thx man. Sometimes when I code in C++ everything seems right, but I always forget something like that.
Jeff D
Suffered seven plagues, but refused to let the slaves go free. ~ Ross Atherton
Thx man. Sometimes when I code in C++ everything seems right, but I always forget something like that.
Jeff D
Suffered seven plagues, but refused to let the slaves go free. ~ Ross Atherton
Suffered seven plagues, but refused to let the slaves go free. ~ Ross Atherton
May someone give me a quick tutorial on Linked-List like the one above? Please...
The road may be long, wind may be rough. But with a will at heart, all shall begone. ~savage chant
The road may be long, wind may be rough. But with a will at heart, all shall begone. ~savage chant
The road may be long, wind may be rough. But with a will at heart, all shall begone. ~savage chant
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement