Linked List

How can I input 10 values(or user given number of values) & output those values using Linked List?
I have this code:
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
#include <iostream>
#include <string>
using namespace std;

struct node{
		int value;
		node *next;
};

int main()
{
	node *head =  NULL;
	head = new node;

	node *p;
	p = new node;

	node *temp;
	temp = new node;
	temp->value = rand()%10;
	temp -> next = NULL;

	head->next = temp;

	for(p=head; p!=NULL; p=p->next){
		
		cout<<p->value<<endl;
	}

	system ("pause");
	return 0;
}


I know there is a major error. What should I do to generate 10 random values?
Topic archived. No new replies allowed.