0

Does anyone know how to delete a specific index of an array? Is there any recommended library out there ?

2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by Narue
0

>Does anyone know how to delete a specific index of an array?
The only way is to overwrite it by shifting every element after the one you want to delete over it. For example:

for ( int i = to_delete + 1; i < n; i++ )
  array[i - 1] = array[i];
--n;
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.