I am working on a project for a class and the first step is to generate an array of 10,000 random integers.
When I write the following code:
#include<iostream>
#include<string>
#include<vector>
#include<time.h>
using namespace std;
int main()
{
int *myarray;
myarray = new int[10000];
for (int i = 0; i < 9999; i++)
{
myarray[i] = (rand() % 10000);
// << myarray[i] << " ";
}
cout << "A random array of 10,000 integers has been generated.";
return 0;
}
The first 4 of the numbers is as follows :
0 6843 30 5756
Every time I add more body to my code or recompile these and the rest of the numbers are always the same.
Is there a way to set my random numbers to be random every single time I compile it?
This is in C++ VS 2015.