Both players get the same random number! ّI want each player to get a different number since they are throwing dice. here is the code:
#include
srand ( time(NULL) ); is used to seed the pseudo-random number generator. time() having a granularity of 1 second, if you seed the PNRG every time you call the roll_a_dice() function, for all the calls made within the granularity period, rand() will end up returning the same random number.
Move the srand ( time(NULL) ); out of the roll_a_dice() function, call that only once in main().
You only need to seed once. Move srand to the top of main and it will work.
srand( int ); is used to initialize a seed.
From there each time you call rand() you'll
get a new random value. By calling srand() in roll_a_dice()
you keep reseting the seed every time. Just move srand()
at the start of your main().