hey guys, im still working on that little turn based game and im trying to add random damage to it. but i think im using rand() wrong.
this is how i am calling it...
i have this function built to take arguements for the random number
and then when i call to it i useCode:int randomNum(int x,int y) { srand(time(0)); int random = rand(); int number = (random % y)+x; return number; }
in that spot im trying to get a random number between 20-40. but when i run my program i know i am getting a number higher than 40 sometimes...so i must be using rand() wrong. any help would be awesome! ThanksCode:int damage = randomNum(20,40);



LinkBack URL
About LinkBacks


