I’m trying to run a 3d array but the code just crashes in windows when i run it, here’s my code;
#include <iostream> using namespace std; int main(){ int myArray[10][10][10]; for (int i = 0; i <= 9; ++i){ for (int t = 0; t <=9; ++t){ for (int x = 0; x <= 9; ++t){ myArray[i][t][x] = i+t+x; } } } for (int i = 0; i <= 9; ++i){ for (int t = 0; t <=9; ++t){ for (int x = 0; x <= 9; ++t){ cout << myArray[i][t][x] << endl; } } } system('pause'); }
can someone throw me a quick fix / explanation
You twice have the line
when you mean
Classic copy-and-paste error.
BTW, if you run this in a debugger and look at the values of the variables, it’s pretty easy to see what’s going on.