after reading inputs to an array:
std::vector<unsigned char *> inputs(elements);
the "inputs" is a 2 dimensional array: inputs[3][2], then reading this array out, the values are:
inputs[0][0]=1
inputs[0][1]=2
inputs[1][0]=3
inputs[1][1]=4
inputs[2][0]=5
inputs[2][1]=6
I would like to read this 2-dimensional array into one dimensional array:
int counter=0;
int * allElements = new int[6];
for(int i=0; i<3; i++)
for(int j=0; j<2; j++)
{
allElements[counter++] = (int)inputs[i][j];
}
That is a traditional way of reading all of the elements into one dimensional array and I believe if I read the elements of "allElements" this way:
for(int i=0; i<6; i++)
printf("%d ", allElements[i]);
and it should be: 1 2 3 4 5 6
However, I would like to read all elements of two dimensional array into the 1 dimensional array such that when I do it like this:
for(int i=0; i<6; i++)
printf("%d ", allElements[i]);
It should be: 1 3 5 2 4 6
In the words, reading all of the first elements of 2 dimensional arrays first.
How can I achieve this way?
unsigned char *instead ofvector<int>?