Hello experts!
ok i'm having a hard time getting it right, ive read some tutorials etc thats how i got to the
point where i could write something but now that ive written this as a function i get errors:
Z:\Profil\Eigene Dateien\Test\Cpp1a.cpp(33)
: error C2065: 'p1' : undeclared identifier
Z:\Profil\Eigene Dateien\Test\Cpp1a.cpp(33)
: error C2228: left of '.x' must have class/struct/union type
Z:\Profil\Eigene Dateien\Test\Cpp1a.cpp(34)
: error C2228: left of '.y' must have class/struct/union type
Z:\Profil\Eigene Dateien\Test\Cpp1a.cpp(36)
: error C2065: 'p2' : undeclared identifier
Z:\Profil\Eigene Dateien\Test\Cpp1a.cpp(36)
: error C2228: left of '.x' must have class/struct/union type
Z:\Profil\Eigene Dateien\Test\Cpp1a.cpp(37)
: error C2228: left of '.y' must have class/struct/union type
Z:\Profil\Eigene Dateien\Test\Cpp1a.cpp(39)
: error C2065: 'p3' : undeclared identifier
Z:\Profil\Eigene Dateien\Test\Cpp1a.cpp(39)
: error C2228: left of '.x' must have class/struct/union type
Z:\Profil\Eigene Dateien\Test\Cpp1a.cpp(40)
: error C2228: left of '.y' must have class/struct/union type
here is the code, keep in mind this is my first C program and I am a total newbie:
#include <stdlib.h>
#include <stdio.h>
double getCenter(double x1, double y1, double x2, double y2, double x3, double y3);
int main()
{
double p1x = 0;
double p1y = 0;
double p2x = 0;
double p2y = 0;
double p3x = 0;
double p3y = 0;
printf ("Enter POINT 1 x co-ordinate: ");
scanf ("%d",p1x);
printf ("\nEnter POINT 1 y co-ordinate: ");
scanf ("%d",p1y);
printf ("\nEnter POINT 2 x co-ordinate: ");
scanf ("%d",p2x);
printf ("\nEnter POINT 2 y co-ordinate: ");
scanf ("%d",p2y);
printf ("Enter POINT 3 x co-ordinate: ");
scanf ("%d",p3x);
printf ("Enter POINT 3 y co-ordinate: ");
scanf ("%d",p3y);
getCenter(p1x,p1y,p2x,p2y,
p3x,p3y);
printf("\nPoint 1 X:%f ", p1.x);
printf(" Y:%f ", p1.y);
printf("\n\nPoint 2 X:%f ", p2.x);
printf(" Y:%f ", p2.y);
printf("\n\nPoint 3 X:%f ", p3.x);
printf(" Y:%f ", p3.y);
printf("\n\nCenter Of Circle X:%f ", x);
printf(" Y:%f ", y);
printf("\n");
}
double getCenter(double x1, double y1, double x2, double y2, double x3, double y3)
{
typedef struct point {
double x;
double y;
} myPoint;
myPoint p1;
p1.x = x1;
p1.y = y1;
myPoint p2;
p2.x = x2;
p2.y = y2;
myPoint p3;
p3.x = x3;
p3.y = y3;
double math1 = p1.x*p1.x + p1.y*p1.y;
double math2 = p2.x*p2.x + p2.y*p2.y;
double math3 = p3.x*p3.x + p3.y*p3.y;
double math4 = p1.x*(p2.y-p3.y) + p2.x*(p3.y-p1.y) + p3.x*(p1.y-p2.y);
double x= (0.5)*(math1*(p2.y-p3.y) + math2*(p3.y-p1.y) + math3*(p1.y-p2.y)) / math4;
double y= -(0.5)*(math1*(p2.x-p3.x) + math2*(p3.x-p1.x) + math3*(p1.x-p2.x)) / math4;
return x,y;
}
could someone please help me out to sort this out? its probably something very easy and stupid
that i just dont see with my newbie eyes