storing an array as an array

Is there a way to set a temporary array of the same dimension as the original array without changing each individual component?

ie. given
1
2
3
4
5
6
7
8
int a[5][5] = {
1, 2, 3, 4, 5,
1, 2, 3, 4, 5,
1, 2, 3, 4, 5,
1, 2, 3, 4, 5,
1, 2, 3, 4, 5};

int b[5][5];


Would it be possible to set each component of b to each respective component of a, without doing something like this:

1
2
3
for (int j = 0; j<5; j++)
     for (int k = 0; k<5; k++)
          b[j][k] = a[j][k];



Thanks in advance.
Last edited on
memcopy may work memcpy(b,a,sizeof(int)*25); ( http://www.cplusplus.com/reference/clibrary/cstring/memcpy/ )
but the loop is far better
I prefer using std::vector for multidimensional arrays. Then it is simply a matter of assigning one object to another.
Topic archived. No new replies allowed.