I have a 2D 3X4 matrix a[3][4]={{0,1,1,0},{1,0,1,0},{0,0,1,1}};
Visually,
0110
1010
0011
Is there a way to assign a vertical strip of a 2D array into a 1D array?
Say, I want to assign the content of 2rd column of the above array into a new 1D array. Output should be
1
0
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int main()
{
int a[3][4]={{0,1,1,0},{1,0,1,0},{0,0,1,1}};
int p[3];
for(int i=0; i<3; i++)
{
p[i] = a[][1];
cout << p[i] << endl;
}
return 0;
}
The error I get is:
error: expected primary-expression before â]â token