title: How to change a particular element of a C++ STL vector
body: <pre><code>vector&lt;int&gt; l;
  for(int i=1;i&lt;=10;i++){
     l.push_back(i);
  }
  </code></pre>
  
  <p>Now, for example, <strong>how do I change the <code>5th element</code> of the vector to <code>-1</code>?</strong></p>
  
  <p>I tried <code>l.assign(4, -1);</code>
  It is not behaving as expected. None of the other vector methods seem to fit.</p>
  
  <p><em>I have used vector as I need random access functionality in my code (using <code>l.at(i)</code>).</em></p>