NULL pointer problem

The problem is at return insert(cap->drt,x,poz--);
(*cap).data CXX0030: Error: expression cannot be evaluated
cap is the head of a double linked list.
It works for the afisare function (cap=cap->drt;) but crashes at insert
Both functions get the same pointer transmitted
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
void afisare(Element *cap)
{
while(cap)
	{
		cout<<cap->data;
		cout<<" -> ";
		cap=cap->drt;	
	
	}
}

Element insert(Element *cap,Element *x,int poz)
{
if(poz==0)
	{
		cap->drt->stg=x;
		cap->stg->drt=x;
		x->drt=cap;
		x->stg=cap;
		exit(0);
	}
else
{
	return insert(cap->drt,x,poz--);
}
}


If needed i can send the whole project.

Tank you !
Topic archived. No new replies allowed.