C++ arrays

1. Initialize array using STL:

const int ArraySize = 1000;
int Array[ArraySize];
std::generate(Array, Array+ArraySize, rand); // Generate random array
for(auto& x : Array) x++;
for(auto x : Array) cout << x;

2. STL array:

array<int,10> MyArray;
MyArray.fill(40); // or 'assign'
for_each(MyArray.cbegin(), MyArray.cend(), 
      [](int n) { std::wcout << n << "\t";} );
auto pArray = MyArray.data();

typedef array<int,10> MyArrayType;
MyArrayType Array1 = {1,2,4,8,16};
MyArrayType Array2;
Array2.assign(64);

Array1.swap(Array2);

if (Array2 == Array1)
    wcout << "Same";
else
    wcout << "Not Same";
</int,10></int,10>

3. copy vector:

auto const numbers = std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
auto results = std::vector{};
std::copy_if(begin(numbers), end(numbers), back_inserter(results), isMultipleOf2);
bool isMultipleOf2(int n)
{
    return (n % 2) == 0;
}

some useful tips (mostly for myself)