Skip to content

Instantly share code, notes, and snippets.

@AndyNovo
Created September 16, 2016 15:40
Show Gist options
  • Select an option

  • Save AndyNovo/64b57087dccd5eb5ab58ccd85e0c43c0 to your computer and use it in GitHub Desktop.

Select an option

Save AndyNovo/64b57087dccd5eb5ab58ccd85e0c43c0 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<int> coll; // vector container for integer elements
// append elements with values 1 to 6
for (int i=1; i<=6; ++i) {
coll.push_back(i);
}
// print all elements followed by a space
for (int i=0; i<coll.size(); ++i) {
cout << coll[i] << ' ';
}
cout << endl;
//example from http://www.josuttis.com/libbook/stl/vector1.cpp.html
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment