I am having a problem with assigning a pointer to a 2d array located in a struct in C. The code runs but I am getting a compilation error and can not understand how to get rid of it.
First, the struct
typedef struct{
double (*cases)[9];
} myStruct;
I then declare a struct of type myStryct and an array in my main program and try to set the pointer in my struct to point at this array:
myStruct a;
double myArray[5][9] = {
{0, 1, 2, 3, 4, 5, 6, 7, 8},
{0, 1, 2, 3, 4, 5, 6, 7, 8},
{0, 1, 2, 3, 4, 5, 6, 7, 8},
{0, 1, 2, 3, 4, 5, 6, 7, 8},
{0, 1, 2, 3, 4, 5, 6, 7, 8},
}
a.cases = &myArray;
The program run fines and I can access elements via the pointer but I get a compilation error: Warning: assignment from compatible pointer type. What is the problem here?