remove elements from an array

Hi!
I have this function
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
	int pos=-1;
	for(int i=0;i<this->nrOfDiets;i++)
	{
		if(name==this->dh[i]->getUsrName()&&date==this->dh[i]->getDate())
		{
			
			delete this->dh[i];
			this->dh[i]=this->dh[this->nrOfDiets-1];
			this->nrOfDiets--;
			pos=1;
		}
	}
	return pos;
}


and if I have 5 elements in my array and want to remove them all I have to run the function 3 times :S
why? and how do I fix it?

best regards: Ogward
Topic archived. No new replies allowed.