I need some help with 3d arrays. I read online that if you want to assign a pointer to a 3d array u'd need to put *** in front, but i get the following error.
error: cannot convert ‘int [1][3][2]’ to ‘int*’ in assignment
i also tried putting *x1 instead of ***x1 but similar issue
I have the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
usingnamespace std;
staticint ***x1;
staticint x,y;
int main() {
int n = 2;
int m = 3;
int x2 [1][3][2];
x1 = x2;
return 0;
}
Thanks for your reply! How would i do it if the array sizes were variables set within main? The problem with that is that n and m wouldn't be defined outside of main.
i.e.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
usingnamespace std;
staticint ***x1;
staticint x,y;
int main() {
int n = 2;
int m = 3;
int x2 [n][n][m];
x1 = x2;
return 0;
}