Double Linked List handling

Hey, Im trying to calculate importance of coordinates.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
void DoubleLinkedList::calculateF()
	{
		Node *p;
		p = first;
		p = p->next;
		double f;
		double LP, PR, LR;
		for (; p != NULL; p)
		{
			if (p->next == NULL)
			{
				p = NULL;
			}
			else{
				LP = sqrt((p->x - p->previous->x)*(p->x - p->previous->x) + (p->y - p->previous->y)*(p->y - p->previous->y));
				PR = sqrt((p->next->x - p->x)*(p->next->x - p->x) + (p->next->y - p->y)*(p->next->y - p->y));
				LR = sqrt((p->next->x - p->previous->x)*(p->next->x - p->previous->x) + (p->next->y - p->previous->y)*(p->next->y - p->previous->y));
				f = (LP + PR) - LR;
				p->F = f;
				p->next;
			}
		}
	}

but im getting error saying : access violation reading location. Could you please look at the code a see if I've done anything wrong?
You haven't shown the definition of the data structure or how the linked list was created.

You first need to work out which loop the crash occurs in. Then you need to examine the values that you use to work out which one is null. Then you need to look back at your program to work out why you set it to null when it shouldn't be.
Topic archived. No new replies allowed.