RSS Forums RSS
Please support our C advertiser: Programming Forums

removing an element...

Join Date: Mar 2007
Location: Honduras
Posts: 1,407
Reputation: Nichito is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 26
Featured Poster
Nichito's Avatar
Nichito Nichito is offline Offline
Nearly a Posting Virtuoso

Re: removing an element...

  #3  
Apr 27th, 2007
there's another solution a bit more complicated than the one from salem (wich is pretty simple, nonetheless pretty accurate to your question), but i'd rather create a temporary array, transer the files from array1[size] into array2[size], delete array1[size], create (again) array1[size-1], and transfer again all information, but the element you wish to remove.

This is pretty useful when you use large arrays and you wish to print them or use them in other processes (with a loop) that could/will use the entire array... this way, you have the amount of elements you need in your array, and you don“t have to worry about the last elements being the same...

This may also work when adding an element to the array, except that when you create the array again, the size must be [size+1], and then you read the information for the last element...
Last edited by Nichito : Apr 27th, 2007 at 1:58 am.
-->sometimes i wanna take my toaster in a bath<--
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 11:22 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC