I've narrowed down a segfault I've been getting to the following code, but I don't know why it's happening.
My structs
Code:
/*Struct to store point*/
typedef struct{
double x;
double y;
}point;
/*Struct to store figures*/
typedef struct{
char name[FIG_LEN +1];
point* coords;
}figure;
The code at fault
Code:
char line[LINE_LEN + 1];
static figure* newFigure;
int coord = 1;
int numCoords = 2;
newFigure->coords = calloc(numCoords, sizeof(point));
I get a segfault on the last line. I"m not sure if I'm accessing the structs in the correct way, is that the problem?
Thanks.