c++ - How to generate a good random seed to pass to srand()? -
I am writing a C ++ program that requires creating a temporary file for my internal use. I would like to allow concurrent hanging of the program by running several processes, so the temporary file name should be random, thus each generated process will generate a unique temporary file name for its own use.
I use Rand () to generate random letters for the part of the file name, so I need to start the random number generator seed using srand ().
What are the options for passing a good debate for srand () that two processes will not be started with the same seed value? My code needs both to work on both Windows and Linux.
Questions actually ask how To create a unique-nominated temporary file.
The operating system probably provides an API for this, which means that you do not have to generate your name.
(also supports Windows tmpfile ()
; However, I 'reports have heard that other people, when it works well on XP, then It fails on Vista if you are on C: Drive and you are not an administrator; GetTempFileName ()
method is best to use with a custom, safe route)
Comments
Post a Comment