This is not how arrays / pointers work in C ++.
This array is stored somewhere in memory. To refer to the same data, you need a pointer pointing to the beginning of the array:
int* temp = logic[2];
Or, if you need a copy of this array, you will have to allocate more space.
Statically:
int temp[9]; for (int i = 0; i < 9; i++) { temp[i] = logic[2][i]; }
Dynamically:
// allocate int* temp = new int(9); for (int i = 0; i < 9; i++) { temp[i] = logic[2][i]; } // when you're done with it, deallocate delete [] temp;
Or, since you are using C ++, if you want to not worry about all these memory materials and pointers, you should use std::vector<int> for arrays with dynamic size and std::array<int> for arrays of static size .
#include <array> using namespace std; array<array<int, 9>, 4> logic = { {0,1,8,8,8,8,8,1,1}, {1,0,1,1,8,8,8,1,1}, {8,1,0,1,8,8,8,8,1}, {8,1,1,0,1,1,8,8,1} }}; array<int, 9> temp = logic[2];