I've used the system time to seed the std random number generator in the past, but for some reason now it is not working. This is on a Mac running OS 10.6.1, compiling with gcc 4.2.1.
The output of this is that the time value changes, but the random seed does not! Here are two example outputs:Code:#include <iostream> #include <stdlib.h> #include <time.h> int main() { unsigned int current_time = time(NULL); srand( current_time ); std::cout << "\nTime: " << current_time << "\tRandom seed: " << srand << std::endl; return 0; }
Time: 1253489088 Random seed: 1
Time: 1253489712 Random seed: 1
Surely I'm missing something obvious! But what?