example4_copying_to_console_output.cpp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>

int main() {
    std::vector<std::string> words = {"Hello", "C++", "World"};

    std::copy(words.begin(), words.end(), 
              std::ostream_iterator<std::string>(std::cout, " "));
    std::cout << std::endl;

    return 0;
}
Back to std_copy