| dasmonk (11) | |||
Ok I want to delete a element that cotains a artist that write in but how will i do that?
| |||
|
Last edited on
|
|||
| dasmonk (11) | |
| I have been trying for long time can someone help me? | |
|
|
|
| guestgulkan (2830) | |||||
|
That isn't going to work. For a start you never move the iterator forward after each check - so what you have is a infinite loop which just keeps rechecking the first item in the list. The next step would be to write it like this: **Example code;**
Should you write your loop in that simple manner - you will find that it will crash if it erases an entry from the list - BECAUSE ERASING AN ITEM FROM A LIST (OR ANY CONTAINER FOR THAT MATTER) WILL INVALIDATE THE ITERATOR. So you can do it in this manner
Note: In the example above we make sure we get all the way through the list and erase any matching entries. If you only want to ease the first item that matches - you could use break; to leave the loop at that point (instead of resetting the iterator back to the start );
| |||||
|
Last edited on
|
|||||
| dasmonk (11) | |
| Thanks!! | |
|
|
|