I was just wondering what I'm doing wrong here? The errors are mostly from my first function, am I calling it wrong?
typedef struct{ //typedef and function prototype
int x, y, radius;
}circle;
int intersect(circle c1, circle c2);
part of the main function that I need for my function
circle c1 = {5, 6, 3.2};
circle c2 = {6, 8, 1.2};
returns 1 if its two circle arguments intersect. How do I call the arrays using struct properly? I keep getting errors
int intersect(circle c1, circle c2){
float cx, cy, r, distance;
cx = (circle c1[0].x - circle c2[0].x) * (circle c1[0].x - circle c2[0].x);
cy = (circle c1[1].x - circle c2[1].x) * (circle c1[1].x - circle c2[1].x);
r = (circle c1[2].x - circle c2[2].x);
distance = sqrt(cx + cy);
if (r <= distance){
return 1;
}else{
return 0;
}
}
I'm preparing for finals, so help will be appreciated
circle c1[0].xmeaning to you? It is not a valid C expression. And I don't understand why you are adding index operators like[1]or[2]... Time to read a good C programming book.