Insert characters into vector. An iterator to the inserted object is returned : vector insert « Vector « C++






Insert characters into vector. An iterator to the inserted object is returned

   
#include <iostream>
#include <vector>

using namespace std;

void show(const char *msg, vector<char> vect);

int main() {
  vector<char> v;

  vector<char>::iterator itr;

  itr = v.begin();

  itr = v.insert(itr, 'A');
  itr = v.insert(itr, 'B');
  v.insert(itr, 'C');

  return 0;
}

void show(const char *msg, vector<char> vect) {
  vector<char>::iterator itr;

  cout << msg << endl;
  for(itr=vect.begin(); itr != vect.end(); ++itr)
    cout << *itr << endl;
}
  
    
    
  








Related examples in the same category

1.Insert element by index
2.Insert element at specific position
3.Insert 10 duplicate value to vector
4.Insert one vector to another vector
5.Insert elements from array
6.Combine insert and end to add elements to the end of vector
7.Create and initialize vector with float number array
8.Appending values to Vector Containers after sorting
9.Inserts an element into a vector at given position