Thread: Two Simultaneous rand() functions with different seed values for srand()

  1. #1
    Registered User
    Join Date
    Jul 2014
    Posts
    1

    Two Simultaneous rand() functions with different seed values for srand()

    Hi All,

    How can I use rand() for two different srand() seed values simultaneously??

    Is there anyway to make two exclusive srand() seeds simultaneous??

    Thanks In Advance.

    Cheers

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,362
    This is not possible with srand and rand. What you can do is to use the random number facilities introduced in C++11, or use some other PRNG implementation that allows you to have multiple independent sequences.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. srand generates same number, no matter what seed
    By christianB in forum C Programming
    Replies: 5
    Last Post: 07-10-2011, 11:28 AM
  2. seed rand not correct values
    By bloodshot772 in forum C Programming
    Replies: 24
    Last Post: 09-29-2010, 02:13 PM
  3. Using rand() and srand() functions
    By Aeria Gloris in forum C Programming
    Replies: 9
    Last Post: 11-05-2009, 11:29 AM
  4. Replies: 3
    Last Post: 05-12-2009, 06:17 AM
  5. Same seed for srand yields different results
    By codegirl in forum C++ Programming
    Replies: 3
    Last Post: 06-23-2003, 02:39 PM

Tags for this Thread