Combining arrays

Hi all!,

I have to think a way to make a single bool array combining four integer arrays.


int bs1[10] = {0}; // int bs1 is an array of 10 zeros

int trng[120]= array of 100 ones and 20 zeros. This zeros are from another array say (int arr[20]= {0} randomly placed in between 100 ones!!

Finally I have to make a bool array combining above mentioned int arrays like

new bool [bs1 + trng]

Can someone suggest a way to do this?

Thanks
What logical operation is the "combination of arrays"? What should it do?
not combination, but combining , i have to get an array of size 130 by combining arrays sizes 120 and 10..


this is what i mean..

new bool [bs1 + trng]

finally it should be

new bool [zeros upto first 10 position and mix of ones and zeros from position 11 to 130 ]
Concatenation.

The question is, what do we know? Do we know during compilation that 'bs1' has 10 elements, 'trng' has 120 elements, and 'barr' has 130 elements? That is static and easy.


Note that the bool datatype has two possible values: true and false. There are implicit conversions to/from integers, but it is better to think booleans as true/false.

It should be trivial to copy+convert N values from one container into third and then copy+convert M values from second container into the third (starting from pos N). Two loops.


There is also std::vector<bool>. See http://www.cplusplus.com/reference/vector/vector-bool/
Thanks a lot!!. I got it
Topic archived. No new replies allowed.