Question: Generate random number in C++ I'm trying to generate a random integer between 0 and 1,000,000 in C++. I keep getting the error signal: segmentation

Generate random number in C++

I'm trying to generate a random integer between 0 and 1,000,000 in C++. I keep getting the error "signal: segmentation fault (core dumped)". Why? And how I can do this?

CODE:

#include #include #include using namespace std;

vector nums; // generates random int between 0 to 1000000 void GenerateRandomInputFiles() {

srand(time(0)); while (nums.size() <=10) { // this generates the random int int randNum = rand()%1000001;

cout << nums[nums.size() - 1] << " "; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!