I have two separate mini-assignments that I need to call to main, and I don't quite understand how to do it. I know that there needs to be a function prototype for each, above main, and then each is included in main before they are eventually called. I just don't know what to include as their parameters. Sample code follows:
Code:
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define NUM_SUITS 4
#define NUM_RANKS 15
/* prototypes */
//some prototype for temperature code
int deal(); //no idea
int main(void)
{
//no idea what to put here
}
void deal(void); //dont really know what to put here
{
bool in_hand[NUM_SUITS][NUM_RANKS] = {false};
int num_cards, rank, suit;
const char *rank_code[] = {"Zero", "One", "Two", "Three", "Four",
"Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen",
"King", "Ace"};
const char *suit_code[] = {"clubs", "diamonds", "hearts", "spades"};
srand((unsigned) time(NULL));
printf("Enter number of cards in hand: ");
scanf("%d", &num_cards);
printf("Your hand:\n");
while (num_cards > 0) {
suit = rand() % NUM_SUITS; /*picks a random suit */
rank = rand() % NUM_RANKS; /*picks a random rank */
if (!in_hand[suit][rank]) {
in_hand[suit][rank] = true;
num_cards--;
printf(" %s of %s\n", rank_code[rank], suit_code[suit]);
}
}
printf("\n");
return 0;
}