vector<int> l;
for(int i=1;i<=10;i++){
l.push_back(i);
}
Now, for example, how do I change the 5th element
of the vector to -1
?
I tried l.assign(4, -1);
It is not behaving as expected. None of the other vector methods seem to fit.
I have used vector as I need random access functionality in my code (using l.at(i)
).