Hello everyone, im new on the forums and I need a little bit of help for this programm (named ask4) that is calculating the distance of a point from (0,0), a point from another one and the area of a triangle. I have a problem with the libraries... (I think)
Point.c:
Code:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "Point.h"
struct POINT
{
double x;
double y;
};
void Display(Point *A)
{
printf("%lf %lf\n",A->x,A->y);
}
double Distance(Point *p1)
{
return sqrt(pow(p1->x,2)+pow(p1->y,2));
}
double Distance2(Point *p1, Point *p2)
{
return sqrt(pow(p1->x - p2->x,2)+pow(p1->y - p2->y,2));
}
double Area(Point *p1, Point *p2, Point *p3)
{
double t;
t=(Distance2(p1,p2)+Distance2(p2,p3)+Distance2(p1,p3))/2;
return sqrt(t*(t-Distance2(p1,p2))*(t-Distance2(p2,p3))*(t-Distance2(p1,p3)));
}
Point.h:
Code:
#include <stdio.h>
#include <string.h>
#include <math.h>
typedef struct POINT Point;
void Display(Point *);
double Distance(Point *);
double Distance2(Point *, Point *);
double Area(Point *, Point *, Point *);
ask4.c:
Code:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "Point.h"
int main(void){
Point p1;
p1.x=15;
p1.y=7;
Point p2;
p2.x=25;
p2.y=14;
Point p3;
p3.x=19;
p3.y=20;
Display(&p1);
printf("%lf\n",Distance(&p1));
printf("%lf\n",Distance2(&p1,&p2));
printf("%lf\n",Area(&p1, &p2, &p3));
return 0;
}
the errors that I get are:
C:\Users\Sifd\Desktop\ask4.c(8): error #2149: Undefined size for 'p1' with type 'Point'.
C:\Users\Sifd\Desktop\ask4.c(9): error #2152: Unknown field 'x' of 'Point'.
C:\Users\Sifd\Desktop\ask4.c(10): error #2152: Unknown field 'y' of 'Point'.
C:\Users\Sifd\Desktop\ask4.c(11): error #2149: Undefined size for 'p2' with type 'Point'.
C:\Users\Sifd\Desktop\ask4.c(12): error #2152: Unknown field 'x' of 'Point'.
C:\Users\Sifd\Desktop\ask4.c(13): error #2152: Unknown field 'y' of 'Point'.
C:\Users\Sifd\Desktop\ask4.c(14): error #2149: Undefined size for 'p3' with type 'Point'.
C:\Users\Sifd\Desktop\ask4.c(15): error #2152: Unknown field 'x' of 'Point'.
C:\Users\Sifd\Desktop\ask4.c(16): error #2152: Unknown field 'y' of 'Point'.