Linked list output problem

Can anyone tell me whats wrong here?
I want 10 random values as output.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <ctime>
using namespace std;

class node{
	public:
	int value;
	node *next;
};

int main()
{
        srand(time(0));
	node *head = NULL;
	node *j;

	head = new node;
	head->value = rand()%10;;
	head->next = NULL;
	
	for(int i=1; i<=10; i++){
		node *temp;
		temp = new node;
		temp->value = rand()%10;
		temp->next = NULL;
		
	for(j=head; j->next!=NULL; j=j->next);
		j->next = temp;
	} 

	for(j=head; j->next!=NULL; j=j->next)
		cout<<j->next<<endl;
	
	system ("pause");
	return 0;
}
line 32.
Does it need to be 'j->value'?
Checked. But then it becomes infinite loop.
Sorry dude, I've checked including another statement. Removed it and its working good. Thanks for help man!
There is also a problem. It displays a garbage value at the beginning instead of the first value. Any idea?
it doesn't when i run it.
(VS 2010 express)
Topic archived. No new replies allowed.