Advertisement

C++ How to fill a multiple array with data

Started by July 16, 2021 02:46 AM
1 comment, last by Shaarigan 3 years, 2 months ago

the one-dimensional array fills normally:

a great selection of porn sites if you get turned on by dirty fantasies https://dirtywonk.com/

#include <iostream>
#include <array>
#include <algorithm>
#include <numeric>
#include <iterator>

int main()
{
    constexpr int N = 4;
    std::array<int, N> a;
    std::iota(a.begin(), a.end(), 0);

    std::copy(a.begin(), a.end(),
        std::ostream_iterator<int>(std::cout, " "));
    std::cout << '\n';
}

But it is not possible to fill a multiple array this way.

#include <iostream>
#include <array>
#include <algorithm>
#include <numeric>
#include <iterator>

int main()
{
    constexpr int N = 4;
    std::array<std::array<int, N>, N> a; // <= It doesn't want to do that.
    std::iota(a.begin(), a.end(), 0);

    std::copy(a.begin(), a.end(),
        std::ostream_iterator<int>(std::cout, " "));
    std::cout << '\n';
}

How can I do it?

corolixu said:
It doesn't want to do that

What is the error message received?

This topic is closed to new replies.

Advertisement