title: Removing elements from an array in C
body: <p>I just have a simple question about arrays in C:</p>
  <p>What is the best way to remove elements from an array and in the process make the array smaller.</p>
  <p>ie: the array is <code>n</code> size, then I take elements out of the array and then the array grows smaller by the amount that I removed it from.</p>
  <p>basically I'm treating the array like a deck of cards and once I take a card off the top of the deck it shouldn't be there anymore.</p>
  <p>EDIT: I'm going to drive myself crazy before the end of the day, thanks for all the help I'm trying the value swapping thing but it's not working right.</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdlib.h&gt;
  
  enum faces { Ace = 0, Jack = 10, Queen, King };
  char *facecheck(int d); 
  int draw(int deck, int i); 
  
  int main() { 
      int deck[52], i, n;
      char suits[4][9] = {
          &quot;Hearts&quot;,
          &quot;Diamonds&quot;,
          &quot;Clubs&quot;,
          &quot;Spades&quot;
      };
  
      n = 0;
  
      for (i = 0; i &lt; 52; i++) {
          deck[i] = n;
          n++;
      };
  
      for (i = 0; i &lt; 52; i++) {       
          if (i % 13 == 0 || i % 13 == 10 || i % 13 == 11 || i % 13 == 12)
              printf(&quot;%s &quot;, facecheck(i % 13));
          else
              printf(&quot;%d &quot;, i % 13 + 1);
          printf(&quot;of %s \n&quot;, suits[i / 13]);
      }
  
      draw(deck, i);
  
      return 0; 
  }  
  
  char *facecheck(int d) {
      static char *face[] = {
          &quot;Ace&quot;,
          &quot;Jack&quot;,
          &quot;Queen&quot;,
          &quot;King&quot;
      };
  
      if (d == Ace)
          return face[0];
      else {
          if (d == Jack) 
              return face[1];
          else {
              if (d == Queen)
                  return face[2];
              else { 
                  if (d == King)
                      return face[3];
              }
          }
      } 
  }
  
  int draw(int deck, int i) { 
      int hand[5], j, temp[j];
  
      for (i = 0; i &lt; 52; i++) {
          j = i
      }; 
  
      for (i = 0; i &lt; 5; i++) {
          deck[i] = hand[]; 
          printf(&quot;A card has been drawn \n&quot;);
          deck[i] = temp[j - 1];
          temp[j] = deck[i];
      };
        
      return deck;
  }
  </code></pre>