Actually what i want to do is to use different structs in same function with same parameter.
Code:
typedef struct{
int x;
int y;
int r;
}Circle;
typedef struct{
int x;
int y;
}Point;
int collisionCircleVsCircle(Circle c1, Circle c2){
if(c1.r + c2.r >= sqrt((c1.x - c2.x)*(c1.x - c2.x) + (c1.y - c2.y)*(c1.y - c2.y))) return 1;
return 0;
}
int collisionPointVsCircle(Point p, Circle c){
if(c.r >= sqrt((p.x - c.x)*(p.x - c.x) + (p.y - c.y)*(p.y - c.y))) return 1;
return 0;
}
typedef struct{
int id;
void *ptr;
}Body;
int collisionBody(Body b1, Body b2){};
I defined a new struct to do what i mentioned above(Body). But how do i give the address information to the Circle and Point (in collisionBody function)?
Do you have a better way?
Does it have a type() function like in interpreted languages?
For example:
Circle circle1;
printf type(circle1);
-->Circle