Passing a 2D array of structs
<p>Im dealing out card type structures from an array. </p>

<pre><code>struct card deck[DECKSIZE];  //The deck is an array of cards structures
</code></pre>

<p>Im using a 2D array. An array of arrays of card type structures </p>

<pre><code>struct card allHands[hands][cards];
</code></pre>

<p>Im using this function passing the deck and the array as pointers with the parameters of the array. I also change the location of the deck pointer to simulate the deck losing the card as it is passed to the player.  </p>

<pre><code>void dealHands(struct card *deck, struct card **handArray, int hands, int cards){

    int players;
    int cardCount;
    int passCard = 0;
    struct card * thisDeck;

    thisDeck = deck;

    for(players = 0; players &lt; hands; players++){
        for(cardCount = 0; cardCount &lt; cards; cardCount++){
            handArray[players][cardCount] = thisDeck[passCard];
            passCard++;
        }   
    }
    deck = (deck + passCard);   
}   
</code></pre>

<p>Its been a long while that I program in c so I think this is how you do the prototype? </p>

<pre><code>    void dealHands(struct card[], struct card*[], int, int);
</code></pre>

<p>This is like the skeleton of my main of how Im implementing the function.</p>

<pre><code>int main(int argc, char *argv[])
{
    /* Declare and initialize variables  */

    int hands = atoi(argv[HANDSINPUT]);  //How many players 
    int cards = atoi(argv[CARDSINPUT]);  //How many cards per hand  
    struct card deck[DECKSIZE];  //The deck is an array of cards structures

    struct card allHands[hands][cards];

    //Builds the deck
    //Shuffles deck with a RNG and swapping every card

    int players;
    int cardCount;
    int passCard = 0;   


    dealHands(deck, allHands, hands, cards);


}
</code></pre>

<p>I get the 2 following statements during compilation </p>

<p>warning: passing argument 2 of ‘dealHands’ from incompatible pointer type [enabled by default]
  dealHands(deck, allHands, hands, cards);
  ^</p>

<p>note: expected ‘struct card **’ but argument is of type ‘struct card (<em>)[(sizetype)(cards)]’
 void dealHands(struct card[], struct card</em>[], int, int);
      ^</p>

<p>I always mess up when it comes to pointers and arrays when I need to call them in a function. So Im not sure where my logic is flawed. Where am I passing the address rather than the value or vice versa?</p>