Let me start by saying that I am quite new to programming in general. The solution might be really obvious.
Basically i need to write a code that randomly generates 10,000 numbers in between 1 and 500 (some numbers will repeat themselves throughout the array. Here is the problem, to give values to said array I meant to put it in a function of type int and go from there, but the array simply wont fit in the function. Is there a way to give a value to all the variables in the array using one loop in this case? can it be done outside a function?
If i try calling it from a function, I get those 2 warning messages:
1) Warning C6262 Function uses '40012' bytes of stack: exceeds /analyze:stacksize '16384'. Consider moving some data to heap.
2) Warning C6201 Index '10000' is out of valid index range '0' to '9999' for possibly stack allocated buffer 'numsinarray'
edit: i work on visual studio 2019
Here's the code
#include <iostream>
#include <random>
using namespace std;
std::random_device seed;
std::mt19937 mersenneTwister(seed());
const int AmountOfNum = 10000;
const int RandomInt(int min, int max);
int NumGen(int min, int max);
int main()
{
}
const int RandomInt(int min, int max)
{
std::uniform_int_distribution<int> distribution(min, max);
return distribution(mersenneTwister);
}
int NumGen(int min, int max)
{
int numsinarray[AmountOfNum];
for (int i = 0; i <= AmountOfNum; i++)
{
numsinarray[i] = RandomInt(1, 500);
}
}