So I have a dynamic array in my struct:
struct Pixel {
int r;
int g;
int b;
} Pixel;
struct Image {
struct Pixel **rgb;
} Image;
Now when i come to use it, I create a fixed array (I know the width and height before coming to the pixels within the image). Here is my code for creating the fixed array:
struct Pixel rgbArray[HEIGHT][WIDTH];
But when I set the array in the struct to this new array:
myStruct->rgb = rgbArray;
warning: assignment from incompatible pointer type [enabled by default]
Because my program crashes when I run it to print the values in my array:
int x, y;
for(y = 0; y < HEIGHT; y++) {
for(x = 0; x < WIDTH; x++) {
struct Pixel newPixel = myStruct->rgb[y][x];
printf("%d %d %d\n", newPixel.r, newPixel.g, newPixel.b);
}
}