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()
.