I learned about rand() and srand() today and was excited because I was trying to figure out a way to do a combat rolling system for a text adventure that I've been working on.
Everything is working mostly the way I want it to but there's this extra number that the code is outputting that I do not want the user to see. I'm 100% positive it has to do with my for statement in the attack function, I'm just not sure how to keep the attacks between 0 and 10 if I use a '0' at
for(i = 1; i <= 1: i++)
^^
Also, I've been messing around with adding an output for if an attack = 9+,
then a critical strike message is printed. Same if the attack = 0, a "miss" message is printed. If nobody gets to this part it is fine I really just want the extra integer to go away
What is the purpose of a for loop? How is that related to the start and end conditions?
What is the relationship between the function parameter (variable i), and it's use in the for loop?
What happens when the return statement is encountered?
After messing around with it then pondering your questions, I realized that I don't even need the for loop to generate the random number... Or the cout line.