title: Insert an element to a vector at run time C++.Throwing Runtime Error
body: <p>I want to insert some element(s) into a vector at the run time.
  Here I go.</p>
  
  <p>The intention is to print <code>"Hello Hi I am Rasmi"</code></p>
  
  <pre><code>int main()
  {
  vector&lt;string&gt;vect;
  vect.push_back("Hello");
  vect.push_back("Hi");
  vect.push_back("Rasmi");
  for(vect&lt;string&gt;::iterator it = vect.begin(); it != vect.end(); ++it)
  {
   if(*it == "Rasmi") // If it encounters "Rasmi"
      { it--;
           vect.insert(vect.begin()+2, "I am");
      }
     cout &lt;&lt; *it;
  }
  }
  </code></pre>
  
  <p>But it throwing run time error.</p>