vector add code example
Example 1: insert at position in vector c++
// where v is the vector to insert, i is
// the position, and value is the value
v.insert(v.begin() + i, v2[i])
Example 2: add to vector c++
// vector::push_back
#include <iostream>
#include <vector>
int main ()
{
std::vector<int> myvector;
int myint;
std::cout << "Please enter some integers (enter 0 to end):\n";
do {
std::cin >> myint;
myvector.push_back (myint);
} while (myint);
std::cout << "myvector stores " << int(myvector.size()) << " numbers.\n";
return 0;
}