Du kannst die Dimensionen als zusätzliche Parameter angeben.
void test(int* arr, int dim1, int dim2, int dim3) {
for (int i = 0; i < dim1; i++) {
for (int j = 0; j < dim2; j++) {
for (int k = 0; k < dim3; k++) {
int value = arr[i * dim2 * dim3 + j * dim3 + k];
printf("%d ", value);
}
printf("\n");
}
printf("\n");
}
}
int main() {
int array3D[2][3][4] = {
{{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}},
{{13, 14, 15, 16}, {17, 18, 19, 20}, {21, 22, 23, 24}}
};
int dim1 = 2, dim2 = 3, dim3 = 4;
test((int*)array3D, dim1, dim2, dim3);
return 0;
}