Answers for "lambda - print-out array and add comment"

C++
0

lambda - print-out array and add comment

#include <functional>
#include <array>
#include <iostream>
#include <string_view>

    std::array<int, 10> s = {5, 7, 4, 2, 8, 6, 1, 9, 0, 3};
 
    auto print = [&s](std::string_view const rem) {
        for (auto a : s) {
            std::cout << a << ' ';
        }
        std::cout << ": " << rem << 'n';
    };
 
    print("Hello");
Posted by: Guest on February-20-2022

Browse Popular Code Answers by Language