An array degrades into a raw pointer to the first array element. So you can do something more like this instead:
#define HAND_SIZE 5
struct Card {
char suit;
char face;
};
void printHandResults(struct Card *hand);
int main(void)
{
struct Card hand[HAND_SIZE];
...
printHandResults(hand);
}
void printHandResults(struct Card *hand)
{
for (int i = 0; i < HAND_SIZE; ++i)
{
// print hand[i].suit and hand[i].face as needed...
}
}
Alternatively:
#define HAND_SIZE 5
struct Card {
char suit;
char face;
};
void printHandResults(struct Card *hand, int numInHand);
int main(void)
{
struct Card hand[HAND_SIZE];
...
printHandResults(hand, HAND_SIZE);
}
void printHandResults(struct Card *hand, int numInHand)
{
for (int i = 0; i < numInHand; ++i)
{
// print hand[i].suit and hand[i].face as needed...
}
}
Alternatively, create a new typedef for the card array, and then you can create variables and pointers of that type:
#define HAND_SIZE 5
struct Card {
char suit;
char face;
};
typedef struct Card Hand[HAND_SIZE];
void printHandResults(Hand *hand);
int main(void)
{
Hand hand;
...
printHandResults(&hand);
}
void printHandResults(Hand *hand)
{
for (int i = 0; i < HAND_SIZE; ++i)
{
// print hand[i].suit and hand[i].face as needed...
}
}