Click here to Skip to main content
15,845,681 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using a vector array by using this code segment.

cliext::vector<long> Characterimgs;

Please can someone tell me how can I remove a particular element from this array. I have used erase() but it didn't work as I wish. I want to remove only one element.Thanks.
[no name] 26-Sep-13 8:07am    
This would be so much easier if you posted your code. You say erase() doesn't work but that is the way to do it.
DianaDil 26-Sep-13 9:36am    

c is the element I want to remove.
pasztorpisti 26-Sep-13 16:35pm    
That's it. At least if c is an index into the array. If you want to remove an item whose value is (long)c then first you have to find it with this: and this returns an iterator for you that you can pass to erase.
MyOldAccount 28-Sep-13 23:01pm    
@ DianaDil,

Can you be more specific, so we can try to help?

Post the problematic code, for start.


Smiljkovic Nenad.

1 solution

erase should actually work. See std::vector::erase[^] for usage sample.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900