after reading inputs to an array:
int * inputs;
the "inputs" is 1 dimensional array: inputs[6], then reading this array out, the values are:
inputs[0]=1
inputs[1]=2
inputs[2]=3
inputs[3]=4
inputs[4]=5
inputs[5]=6
I would like to read this array into another one dimensional array:
int counter=0;
int * allElements = new int[6];
for(int i=0; i<6; i++)
{
allElements[counter++] = inputs[i];
}
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 that 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
How can I achieve this way?
new? Use the standard library containers for arrays (vectororarray).