I'm trying to pass an three dimensional array to a function like this:
void example( double*** bar ) {
// Stuff
}
int main() {
double[3][2][3] foo;
// Initialize foo
example( foo );
return 0;
}
This causes the gcc to give me "Invalid pointer type". How am I supposed to be doing this? I could just make the entire argument a one-dimensional array and arrange my data to fit with that, but is there a more elegant solution to this?
edit:
In addition, I can't always specify the length of each sub-array, because they may be different sizes. e.g.:
int* foo[] = { { 3, 2, 1 }, { 2, 1 }, { 1 } };
If it helps at all, I'm trying to batch pass inputs for Neurons in a Neural Network. Each Neuron has a different number of inputs.
void example(int *bar[])and passfoo, but correctly processingbaris just as difficult as correctly processingfoo. One simple solution would be including a "stop marker" in the array, e.g.int* foo[] = { { 3, 2, 1, -1 }, { 2, 1, -1 }, { 1, -1 }, { -2 } };(but please replace the magic numbers with symbolic constants!)