I've tried creating a reference to the pointer and modifying that, like this, but that hasn't worked either.
Code:
float **temp = &inverseMatrix;
temp[0][0] = 8;
I've also tried setting the reference equal to another matrix by doing
Code:
float **temp = someMatrix;
I have no clue where to go next. I've been reading forum posts and have tried adding a * in front but that just results in compilation errors. What is the correct way to modify a global variable from a method that is not main?
Code:
float** inverseMatrix;void change();
void printMatrix(const float **matrix, int rows, int columns);
int main()
{
int j;
inverseMatrix = (float**)malloc(8 * sizeof(float *));
for (j = 0; j < 8; j++)
{
inverseMatrix[j] = (float*)malloc(8 * sizeof(float));
}
change();
printMatrix(inverseMatrix, 8, 8);
}
void change()
{
for (int i = 0; i < 8; i++)
{
for (int j = 0; j < 8; j++)
{
inverseMatrix[i][j];
}
}
printMatrix(inverseMatrix, 8, 8);
}