Hi I've been trying to figure this out for hours now and I can't get it so I thought I'd ask the genious' here for help. The assignment is to create three functions based on the main. I got them all except the last one, the search one. When i run the program I get "error vector subscript out of range" when it goes through the second cycle.
I checked the debugger and it seems it's trying to go to vector[3], which doesnt exist, and it understandably errors. I cant figure out why its going that far, since in my for loop it says until less than the size of the vector, which means 2.
I'm also NOT ALLOWED to change the main IN ANY WAY SHAPE OR FORM, only to implement functions that work accordingly. Thanks again.
Heres the code:
#include <iostream>
#include <vector>
using namespace std;
void processVector(vector<int>&);
void print(const vector<int>&);
bool search(const vector<int>&, int);
/***** DO NOT MODIFY THE MAIN FUNCTION *****/
int main()
{
vector<int> intList;
/**** FUNCTION processVector() ****/
//Uncomment the following statement
// AFTER implementing processVector()
processVector(intList);
//OUTPUT (as the user, enter: 1 2 3 -1)
/*
Enter a positive number (to quit enter -1): 1
Enter a positive number (to quit enter -1): 2
Enter a positive number (to quit enter -1): 3
Enter a positive number (to quit enter -1): -1
*/