Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 8th, 2012  |  syntax: None  |  size: 0.56 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Remove element from a list in C  
  2. Account AccountList::remove(int i){
  3. if(i>=0 && i<size()) {
  4.     for (int n = i; n < size(); n++) {
  5.         if(i+1!=size()) {
  6.             aList[n]=aList[n+1];
  7.         }
  8.     }
  9.     sz--;
  10.     return aList[i];
  11. } else {
  12.     return Account();
  13. }
  14. }
  15.        
  16. Account AccountList::remove(int i)
  17. {
  18.   if(i>=0 && i<size())
  19.   {
  20.     Account a = aList[i]
  21.     for (int n = i; n < size() - 1; n++)
  22.     {
  23.         if(i+1!=size())
  24.         {
  25.             aList[n]=aList[n+1];
  26.         }
  27.     }
  28.     sz--;
  29.     return a;
  30.   } else
  31.   {
  32.     return Account();
  33.   }
  34. }