Hello I am struggling to find a solution Ive defined the following 3D array of structures.
typedef struct{
float x;
float y;
float z;
} Point;
Point ***Qw;
Qw = malloc(num_bezier * sizeof(Point **));
for(i=0; i<num_bezier; i++){
Qw[i] = malloc((m+1) * sizeof(Point *));
for(j=0; j<=m;j++)
Qw[i][j] = malloc((p+1) * sizeof(Point));
}
I can loop through the array to print its contents but at some point of the program after modifying some of the elements, Im no longer able to access some of the structs in the array and i get a segfault. Any help appreciated, thanks.
PD: Ive just noticed i had defined incorrectly my struct...
typedef struct{
double x;
double y;
float z;
} Point;
As soon as i exchanged the double for float type it fixed the segfault... still trying to figure out why it was segfaulting
As soon as i exchanged the double for float type it fixed the segfault.It's not fixed. There is still a problem hidden in your code which could surface elsewhere again.