954,506 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

array index deletion

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

k2k
Posting Whiz
352 posts since Nov 2007
Reputation Points: 15
Solved Threads: 1
 

>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;
Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You