#include #include #include "cards.h" #include "blackjack.h" /* this function seeds the random number generator */ /*** call this function with 0 at the beginning of main ***/ void init_rand (int seed) { if (seed == 0) { struct tm *tm_ptr; time_t clock; clock = time (NULL); tm_ptr = gmtime (&clock); srand (tm_ptr -> tm_sec); } else srand (seed); } /* this function allows the user to enter a value to seed the random number generator */ void set_seed () { int val; printf ("\nPlease enter seed value (0..32000): "); scanf ("%d", &val); init_rand (val); } /* this function reads in a loaded deck from an ASCII file */ void read_deck (DECK_T *deck) { FILE *fp; char name [30]; int i; printf ("\nPlease enter file name with deck data: "); scanf ("%s", name); if ((fp = fopen (name, "r")) == NULL) { printf ("invalid file namen"); return; } for (i = 0; i < NUM_CARDS; i++) { fscanf (fp, "%d %c", &(deck -> cards [i].value), &(deck -> cards [i].suit)); } } /*** define other functions, as listed in cards.h, here ***/ /*** you may also need some additional helper functions local to this source file -- they can be defined here also ***/