const char* GetRandomGenState_ns ( randgen_ns*  rand,   const char*  options )

Returns a string that can be used as a seed to NewRandomGenerator_ns to create a random generator that will produce exactly the same pseudo-random results as this one will.

So you can save the state of a random generator to later make an equivalent generator.

The results returned are only valid until the next operation using rand, so you should duplicate the string returned.

The string returned will always be a null terminated C string of printing ascii characters, so it can be easily printed to a file.

Pass NULL for options; it is only for future expansion.

NOTE: As an alternative to using this function, you can create a new randgen_ns with NewRandomGenerator_ns, remember the seed value used, and use the new generator instead of this one. Then in future, to obtain the same sequence of random results, instead of using the saved state to create the randgen_ns, you use the remembered seed.


Versions 5.02 and later have this function.

See also:

NewRandomGenerator_ns    Create a new randgen_ns with the value returned.


See NewRandomGenerator_ns.