Need help looping

Mar 6, 2013 at 8:00pm
I am writing a program and it works but I am using the following:
num1= rand() % 6 + 1;
num2=rand() % 6 +1;

but I have conditions that if num1& num2 are 1 then you get a score of zero but if my programs hits a 1 then it just keeps generating 1 again the same exact numbers for the player for like 1 sec or 2, then I gives new numbers. How can I keep this from happening? Everything else seems to work just fine.

note: I am also using a function separate from main and it is supposed to return a value being total. Num1 and Num2 are the ones that generated the total.

Thanks,
Mar 6, 2013 at 8:09pm
I'm guessing that you are not seeding your rand, if you don't seed then rand() will generate the same number every time.

 
srand (time(NULL));
Mar 6, 2013 at 10:45pm
closed account (3CXz8vqX)
Damn so that's what I was doing wrong... thanks Scorpic. (No I'm not michelle but I found your point just as useful as I had a similar problem).
Topic archived. No new replies allowed.