array function

Hi
how i can remove elenment from array by using funtion?
What do you mean by remove? An array has a fixed size that can't be changed.
I have 10 numbers that are sorted. I don't want num 6 and replace next number in the place of 6.
this belongs more to the Begginer forum section, but whatever. Thats not how arrays work Ajiel.

int array[10] = {1,2,3,4,5,6,7,8,9,10};

this will be an array of 10 numbers.

array[6] = 69;

will turn your array into {1,2,3,4,5,6,69,8,9,10}

however if you want to remove a number completly, you will have to move everything else after it one space back like this.

1
2
3
4
//this will "remove" array[6]
for(int i = 7; i<10; ++i){
      array[i-1] = array[i];
}


resulting in the following

{1,2,3,4,5,6,8,9,10,10}

notice that the last element is still 10, there is no way to make the array smaller, unless you dont mind making a second array.
Topic archived. No new replies allowed.