title: Erasing a pair from vector and reserving space for vector pair
body: <pre><code>#include&lt;iostream&gt;
  #include&lt;vector&gt;
  #include&lt;algorithm&gt;
  using namespace std;
  vector &lt; pair &lt;string,int&gt; &gt; ivec;
  //ivec.reserve((pair &lt;string,int&gt;)(10);
  void logout(int id)
  {
      vector &lt; pair&lt;string,int&gt; &gt; :: iterator iter=ivec.begin();
      while(iter!=ivec.end())
      {
          if(iter-&gt;second==id){
              ivec.erase(iter);
          }
          ++iter;
      }
  
  }
  void login(char str[],int id)
  {
      pair&lt;string,int&gt; temp;
      temp.first=(string)str,temp.second=id;
      ivec.push_back(temp);
  }
  int main(void)
  {
      int ch;
      pair&lt;string,int&gt; temp;
      temp.first="server",temp.second=0;
      ivec.push_back(make_pair("server",0));
      while(true)
      {
          char name[10];
          int id;
          cin&gt;&gt;name;
          cin&gt;&gt;id;
          cout&lt;&lt;"login"&lt;&lt;endl;
          cin&gt;&gt;ch;
          if(ch==1)
          {
              login(name,id);
          }
          else
          {
              break;
          }
      }
      cout&lt;&lt;ivec.size();
      logout(6);
      cout&lt;&lt;ivec.size();
  }
  </code></pre>
  
  <ol>
  <li>The logout function to erase the pair from the vector works fine but for erasing the last element it gives a run time error.</li>
  <li>I want to reserve space for this vector type but not know the correct syntax to do the job</li>
  <li>Please answer according to c++ 98 standard</li>
  <li>I am very new to vector and stl so if there is something evern very trivial do mention.</li>
  </ol>