#include <stdio.h>
struct point
{
int x;
int y;
};
struct rectangle
{
struct point p1;
struct point p2;
};
struct point createpoint(int x, int y);
struct rectangle setpoints(struct point p1, struct point p2);
int main(void)
{
struct point p1;
struct point p2;
struct rectangle r1;
p1 = createpoint(1, 3);
p2 = createpoint(30, 15);
r1 = setpoints(p1, p2);
printf("r1.p1.x = %d r1.p1.y = %d\n", r1.p1.x, r1.p1.y);
printf("r1.p2.x = %d r1.p2.y = %d\n", r1.p2.x, r1.p2.y);
return 0;
}
struct point createpoint(int x, int y)
{
struct point p;
p.x = x;
p.y = y;
return p;
}
struct rectangle setpoints(struct point p1, struct point p2)
{
struct rectangle r;
r.p1.x = p1.x;
r.p1.y = p1.y;
r.p2.x = p2.x;
r.p2.y = p2.y;
return r;
}
/*
run:
r1.p1.x = 1 r1.p1.y = 3
r1.p2.x = 30 r1.p2.y = 15
*/