Hi, I have a error with one of my programs. I'm supposed to get rid of negative numbers when there are numbers that are randomly generated.
Here is the middle part of the code.
{
int vectorLength = 10;
vector<int> bothSigns(vectorLength);
cout << " Input vector: ";
for (int i = 0; i < vectorLength; i = i + 1)
{ bothSigns[i] = rand()%201 - 100;
cout << "\t" << bothSigns[i];
}
cout << "\n";
vector<int> noNegs;
////////////////////////////////////////////
for(int i = 0; i < vectorLength; i = i + 1)
{
if(bothSigns[i] > 0)
{
bothSigns.push_back(noNegs[i]);
}
}
The part where i'm supposed to start is after the /////'s. However, whenever I input a number for the random numbers(not put in part of code), i keep getting a segmentation error.