I am working on a linked list, and have the list working correctly. I am not modifying my Node class to generate a pseudo random key. After playing with the srand() parameter for initialization, I came up with this:
1 2
srand( time(NULL) + (int)&data );
key = rand();
(This is inside my Node constructor, which has access to a just-initialized 'data' field by a parameter passed in to constructor):
The address for the 'data' field seems different every time, and how randomly assigned is it? My understanding is that the OS deals with which memory to allow my program to allocate to 'data' in this case.
Ahh yes.. I knew this, and thought nothing of it when I wrote that bit. Thanks.
As far as using the address of a variable assigned at runtime - does this enhance the randomness? I understand that a true random number is based on pure randomness (noise from a superconductor, keystrokes, interrupt threads?) etc. How about addresses of variables?