Aug 12, 2019 at 7:58am
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;
}
Aug 14, 2019 at 4:43pm
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 Aug 14, 2019 at 4:45pm
Aug 14, 2019 at 4:45pm
@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 Aug 14, 2019 at 4:46pm
Aug 15, 2019 at 10:43am
@fewdiefie
You forgot that a
is a 2D array, so a[0]
is the address of a 1D row in that array.