1. Help With Linked List Code

I am trying to write a program that counts how many points are within the radius of a circle. The user chooses the x and y coordinates of the center of the circle, the radius of the circle, the x and y coordinates of the points, and the program responds with how many of those points are in the circle. This is what I've tried, but it only counts the total number of points. Can't figure out what I'm doing wrong!
Code:
typedef struct {
float x, y;
} Point;
/* PointListNode -- A node of a singly-linked list of points */
typedef struct PointListNode{
Point *p;
struct PointListNode *next;
} PointListNode;

int count_nearby_points(PointListNode *pointList, Point* centrePoint, float radius){
PointListNode* current = pointList;
float xDistance, yDistance, length;
int count=0;
while (current != NULL){
xDistance = (pointList->p->x) - (centrePoint->x) ;
yDistance = (pointList->p->y) - (centrePoint->y) ;
length = sqrt((xDistance*xDistance)+(yDistance*yDistance));
count++;
}
current = current->next;
}return count;

} /* count_nearby_points */ 2. If the center point is not at the origin you need the general form of the circle equation. You already know r2 = x2 + y2. Well the general form is
r2 = (x-h)2 + (y-k)2
where (h,k) is the center point.

This means that you can calculate a certain distance and see if it's less than a given diameter.
Code:
if ((x-h) * (x-h) + (y-k) * (y-k) < r * r)
puts("The point is in the circle"); 3. Is that not what line 16-20 of my code does though? 4. In the listing above on lines 16 and 17, you're accidentally using pointList where you should be using current. So you're only really just testing the first element over and over as current moves through the list. 5. That fixed it! I knew it was just something simple I was missing. Thankyou! Popular pages Recent additions circle, float, points, radius, struct 