I am trying to do this, but it is giving me "initializer fails to determine size of ‘b’"
int main()
{
int a[12][2];
a[0][0] = 1;
a[0][1] = 1;
int b[][2] = a[0];
return 0;
}
you can't do that in c++m you have to do it this way:
1 2 3 4 5 6
|
int b[12][2];
for( int i = 0; i < 12; i++ )
{
b[ i ][ 0 ] = a[ 0 ];
b[ i ][ 0 ] = a[ 1 ];
}
| |
Last edited on
@coder777
your code is wrong, here is the correct version:
|
std::copy( a, a + 2, b );
| |
and you have to
#include <algorithm>
to use
std::copy
Last edited on
@fewdiefie
You forgot that a
is a 2D array, so a[0]
is the address of a 1D row in that array.