I'm using C++ on Visual Studio 2010. The problem is that I try to generate an array of random numbers, but the results are always the same on every run. For example:
Run 1:
[0 20103 43281 37162 101 299]
Stop
Run 2:
[0 20103 43281 37162 101 299]
Stop
...
So, my code is generating random values for the array, but they are always the same values everytime I run the code (even if I clean the build). I really need to generate random values for every run.
Here's some sample code, the complete code is full of simple operations:
...
srand(time(NULL));
for (int i = 0; i < 31; i++){
x[i] = x[i] + rand();
}
Any ideas?
Please, note the presence of the srand(time(NULL));
line. It's already on the code, still the output is not fine.