Hi everyone I got a trouble with the returning element of a function. I need to return a double pointer to pointer "double**". But I got a double[][] matrix.
Here is the code:
double** createPalette(int r, int g, int b) {
double incR = 1 / r, incG = 1 / g, incB = 1 / b;
double Cp[r * g * b][3];
for (int i = 0; i < r; i++) {
for (int j = 0; j < g; j++) {
for (int k = 0; k < b; k++) {
Cp[i * r + j * g + k][0] = incR * i;
Cp[i * r + j * g + k][1] = incG * j;
Cp[i * r + j * g + k][2] = incB * k;
}
}
}
return Cp; //return &cp... (?)
}
I was looking for on internet, but I only found about simple pointer, no pointer to pointers.What should I do? Thanks for all.