You are generating the random number correctly, just not using it correctly.
1) You don't need all that preamble to set up seconds and call srand(). It's easier (and less confusing) if you simply replace lines 10-12 with srand(time(NULL)). Generating seconds is obviously confusing you.
2) You output a random number but didn't store it so you have nothing to compare your input with.
WaltP
Posting Sage w/ dash of thyme
11,404 posts since May 2006
Reputation Points: 3,421
Solved Threads: 1,055
Skill Endorsements: 37
I think you should try this approach too.
Where do you imagine he used it? Look at his code again... :rolleyes:
WaltP
Posting Sage w/ dash of thyme
11,404 posts since May 2006
Reputation Points: 3,421
Solved Threads: 1,055
Skill Endorsements: 37
you can declare them on the same line... it looks cleaner
I disagree, but that's just programmer's preference...
WaltP
Posting Sage w/ dash of thyme
11,404 posts since May 2006
Reputation Points: 3,421
Solved Threads: 1,055
Skill Endorsements: 37
Question Answered as of 8 Months Ago by
phorce,
WaltP,
Vish0203
and 3 others