problem with aray removal...

Hi,,
I have a small problem with my code. I have an array with a list of numbers from o to n.. And n is the calculated value from a formulae.. I placed them in a array and i generate a random number which is present in the array and remove it and place the next number in its place and so on... i am placing the code down here..

int rwall[total];
for(int i=0;i<total;i++)
{
rwall[i]=i;
}

for(int i=0;i<=no;i++)
{
if(i==no)
{
// If the number matches with the nummber in array
// i am going to a label called rem.. There i am moving
the numbers one position forward...
goto rem;
}
rem:
{
for(int j=no;j<wall;j++)
{
rwall[j]=rwall[j+1];
cout<<rwall[j]<<endl;
}
}
}

The "no" is the position in the array to be removed.. Kindly help me with this...
What errors are you getting?
What is the value of "wall"?
It should be total-1 or less. Otherwise rwall[j+1] will be out of bounds.
Also, avoid using goto whenever you can.
The structure of your code is not right. Note that rwall[i] == i, so rwall[no] == no. You don't need the for loop. You may want to check if "no" is in range [0; total)...
Lastly, use code tags next time
Good luck
Thanks for the reply.. But my basic question is i have an interger array with numbers from 1 to n.... Whenever i get a value called no,i should delete the element in the array at this position(no)... And push the other numbers after this deleted number before by one... Can you write a code snippet for me....?
Topic archived. No new replies allowed.