I
Immortal Nephi
The array has 2D matrix. 2D matrix contains two rows and two
columns. I want to create multiple 2D matrixs into array. It looks
like 3D array. My code is easier to select which matrix I want to
use.
How do I use reference to pick up 2D matrix?
int main()
{
unsigned char xx[ 2 ][ 2 ][ 2 ] =
{
{ // First Matrix
{ 1,2 },
{ 3,4 }
},
{ // Second Matrix
{ 5,6 },
{ 7,8 }
}
};
unsigned char (*x)[2] = &xx[ 0 ][ 0 ][ 0 ]; // Error Matrix 1
unsigned char y1 = x[0][0];
unsigned char y2 = x[0][1];
unsigned char y3 = x[1][0];
unsigned char y4 = x[1][1];
(*x)[2] = { &xx[ 1 ][ 0 ][ 0 ] }; // Error Matrix 2
unsigned char y5 = x[0][0];
unsigned char y6 = x[0][1];
unsigned char y7 = x[1][0];
unsigned char y8 = x[1][1];
return 0;
}
columns. I want to create multiple 2D matrixs into array. It looks
like 3D array. My code is easier to select which matrix I want to
use.
How do I use reference to pick up 2D matrix?
int main()
{
unsigned char xx[ 2 ][ 2 ][ 2 ] =
{
{ // First Matrix
{ 1,2 },
{ 3,4 }
},
{ // Second Matrix
{ 5,6 },
{ 7,8 }
}
};
unsigned char (*x)[2] = &xx[ 0 ][ 0 ][ 0 ]; // Error Matrix 1
unsigned char y1 = x[0][0];
unsigned char y2 = x[0][1];
unsigned char y3 = x[1][0];
unsigned char y4 = x[1][1];
(*x)[2] = { &xx[ 1 ][ 0 ][ 0 ] }; // Error Matrix 2
unsigned char y5 = x[0][0];
unsigned char y6 = x[0][1];
unsigned char y7 = x[1][0];
unsigned char y8 = x[1][1];
return 0;
}