dimanche 25 septembre 2016

rand() only sets variable to 0

I am working on a rock, paper, scissors game and one of the ways I am setting the computer's choice is through rand(). I #include , seed rand at the start of main with srand (time(0)); and I call it in a function definition with computerWeaponChoiceV = (rand() % 3) + 1;. However, when I test my program it always prints computerWeaponChoiceV to be 0.

Am I doing something wrong with rand()? If you need more of my code please let me know.




Aucun commentaire:

Enregistrer un commentaire