Queue problems

Hi guys.

May you please help.I need to write a function that finds and romoves a provided argumnent in my array.Once I remove it all the other members in the queue should be shifted up in the queue.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 void  Validate :: remove(List* b)// list is nother class which has a relationship with Validate class.
{
	for(int i =0; i < max;i++)
	{
		if(queue[i] == b)
		{
			queue[i] = 0;
		}
	}
	for(int i = 0; i< max; i++)
	{
		queue[i] = queue[i + 1];
	}
	max--;
}


But for some reason I cannot remove it from the array.

Thanks in advanced..
The 'queue' is apparently an array of List pointers.

Your first loop implies that queue can contain multiple copies of the same value.
Your second loop does a wild rampage on everything and then some.

Lets say queue starts as { 1, 2, 3, 2 }. max==4
Remove "2". After first loop:
{ 1, 0, 3, 0 }. max==4

After second loop:
{ 0, 3, 0, X }, where X equals 0 plus whatever was in memory location that is after the last element of the array.
what do you mean in you cannot remove it from the array ?
Topic archived. No new replies allowed.