Hi I hope I got the topic right..
that's what I'm doing:
create P(variable) polygons each having a variable numbers of vertices,
something in my mallocs is wrong... since I get weird results.
help?
#include <stdio.h>
#include <stdlib.h>
typedef struct point
{
double x, y;
} point;
typedef struct polygon
{
int n;
point *v;
} polygon;
typedef struct line
{
point p1, p2;
double A, B;
} line;
#define P 2
int main()
{
int i = 0, j = 0;
polygon *obstacles = malloc(sizeof *obstacles * P);
for(i = 0; i < P; i++)
{
obstacles[i].n = i + P * 2;
obstacles[i].v = malloc(sizeof obstacles[i].v * obstacles[i].n);
for(j = 0; j < obstacles[i].n; i++)
{
obstacles[i].v[j].x = obstacles[i].n;
obstacles[i].v[j].y = obstacles[i].n + 5;
}
}
}