// Remove items/s
for(int i=_itemCount;i>0;--i) //start the check at the top of the array moving down
if(_items[i].getStatus() == "remove") // checks status and executes if = "remove"
for(int j = i; j<_itemCount;++j) // starts at point on array remove is found and counts up
_items[j] = _items[j+1]; // copying down 1 until end of array is reached
_itemCount--; // -1 from array
} //performs process again until no "remove"s are found
I want to start from the top of the array and move down checking each item, if the items status = "remove" then I want to copy all the data above in the array down 1, and then -1 from '_itemCount' the number of items in the array.
This function isn't working and I'm not sure why?...
Difficult to diagnose without seeing the class declaration for ItemGen.
However a couple of things are obvious:
1) Assuming _itemCount is the number of items in the array, the following statement is going to index past the end of the array on the first pass through the loop:
if(_items[i].getStatus() == "remove")
2) Your second loop is also going to start past the end of the array.
PLEASE USE CODE TAGS (the <> formatting button) when posting code.
That's not going to work. Let's assume item is to be removed. The first iteration of the loop, both i and j are 5 resulting in item overwriting itself, essentially a noop but poor practice. Second iteration of the loop item overwrites item. Not what we want. You want item to overwrite item continuing until all remaining items have been moved.