Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

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 << '
';
    };
 
    print("Hello");
Source by en.cppreference.com #
 
PREVIOUS NEXT
Tagged: #lambda #array #add #comment
ADD COMMENT
Topic
Name
9+3 =