To concatenate two 2-dimensional int arrays into one larger 3-dimensional array

How can I concatenate two 2-dimensional int arrays into one larger 3-dimensional array. This question is also valid for the 3-dimensional vectors.
I know the command for the one dimensional vector as:
1
2
3
4
std::vector<int> results;
results.reserve(arr1.size() + arr2.size());
results.insert(results.end(), arr1.begin(), arr1.end());
results.insert(results.end(), arr2.begin(), arr2.end());

and for the one dimensional array as:
1
2
3
int * result = new int[size1 + size2];
copy(arr1, arr1 + size1, result);
copy(arr2, arr2 + size2, result + size1);

But I do not know how to make a 3-dimensional array or vector.
Last edited on
std::vector<std::vector<int>> v1( 10, std::vector<int>( 10 ) );
std::vector<std::vector<int>> v2( 10, std::vector<int>( 10 ) );
std::vector<std::vector<std::vector<int>>> v3 { v1, v2 };
And what about arrays?
What is 10 in your first two lines of code?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <string.h>

int main() 
{
   int v1[] = {0,1,2,3,4,5,6,7,8,9};
   int v2[] = {0, 100,200,300,400,500,600,700,800,900};
   int v3[2][sizeof(v1)/sizeof(int)];

   int* p = v3[0];
   memcpy(p, &v1, sizeof(v1));
   memcpy(p+=(sizeof(v2)/sizeof(int)), &v2, sizeof(v2));

   return 0;
}
Topic archived. No new replies allowed.