The goal here == i'm trying to push_back a string value into a vector.... issues arises such as (vector subscript out of range)
i've made a function that accepts a string vector as a parameter
i've made a for loop inside that function utilizing a variable combined with a 'cin' function
all i got back is 'vector subscript out of range'... how? am i missing something?
#include <iostream>
#include <vector>
#include <string>
void sentDef(std::vector <std::string> sentienceVar) {
std::string terms;
std::cout << "input how many terms/variables made" << std::endl;
int howManyVar;
std::cin >> howManyVar;
for (int i = 0; i < howManyVar; i++) {
std::cin >> terms;
sentienceVar.push_back(terms);
}
}
int main() {
std::vector <std::string> sentienceVar;
sentDef(sentienceVar);
std::cout << sentienceVar[0] << std::endl;
system("pause");
}