cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
rand() function always returns the same
rand() function always returns the same value
Jun 30, 2011 at 6:06pm UTC
TexanMonkey
(55)
For some reason, when ever I use the
rand()
fuction, it always returns the same value.
How do I fix this?
Jun 30, 2011 at 6:06pm UTC
Moschops
(7244)
Do you always seed it with the same value?
Jun 30, 2011 at 6:07pm UTC
TexanMonkey
(55)
Whats a seed?
Jun 30, 2011 at 6:09pm UTC
Moschops
(7244)
http://www.cplusplus.com/reference/clibrary/cstdlib/rand/
First seed rand with srand()
Then call rand()
Jun 30, 2011 at 6:10pm UTC
TexanMonkey
(55)
Thanks that sovled my problem!!!
Topic archived. No new replies allowed.