How to delete an element from an array?

Hello, I am learning on arrays and I have to learn how to delete an element(s) from an array; suppose I have an array x[10] = {1,2,3,4,5,6,7,8,9,10}, and I want to delete array{5} so that the values of the array become {1,2,3,4,5,7,8,9,10}; how do I go about this?
This is not the same as setting the value of array{5} to null; but completely eliminating it so that it does not get printed alongside the other elements of the screen. Somebody, please help out, thanks.
You can't.

An array is a fixed length structure. You can't resize it. You can simulate deletion by moving the content, but that's about it.

The standard library provides std::vector, which you can think of as a resizeable array.
Thanks kbw, for your prompt response, but there has to be some sort of manipulation; that allows the user to shift all the elements of the array to the left and then removing the last element in the array; my teacher said so; and he said to find it :)
There is, but as you can't resize an array, the best you can do is move it to the end. With a vector, the final step would be to reduce it's size to remove the end element(s).

I think what you're looking for is the Remove erase idiom.
http://en.wikipedia.org/wiki/Erase-remove_idiom
Topic archived. No new replies allowed.