How to generate a good random seed to pass to srand()?

Posted by zr on Stack Overflow See other posts from Stack Overflow or by zr
Published on 2010-02-02T14:26:57Z Indexed on 2010/04/28 22:17 UTC
Read the original article Hit count: 286

Filed under:
|
|

Hi,

I am writing a C++ program which needs to create a temporary file for its internal usage. I would like to allow concurrent executions of the program by running multiple proccesses, so the temporary file name needs to be randomized, that way each spawned process will generate a unique temporary file name for its own use. I am using rand() to generate random characters for part of the file name, so i need to initialize the random number generator's seed using srand(). What options are there for passing a good argument to srand() such that two processes will not be initialized with the same seed value? My code needs to work both on Windows and pn Linux

TIA.

© Stack Overflow or respective owner

Related posts about c

    Related posts about c++