Skip to content

Instantly share code, notes, and snippets.

@samuelsmal
Created November 4, 2014 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samuelsmal/cbb8ecd71199984d56e9 to your computer and use it in GitHub Desktop.
Save samuelsmal/cbb8ecd71199984d56e9 to your computer and use it in GitHub Desktop.
Printing a vector to stdout
#include <vector
#include <algorithm> // for copy, for_each
#include <iterator> // for ostream_iterator
std::copy(vector.cbegin(), vector.cend(), std::ostream_iterator<vector_element_type>(std::cout, " "));
std::for_each(vec.cbegin(), vec.cend(), [] (const vector_element_type c) {std::cout << c << " ";});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment