I am new to C++, and am continuously told to use std::vector instead of new[].
I am trying to achieve this functionality, in where I know the size of the vector and want to assign to it randomly (not sequentially).
However, when running this, my program terminates with no error output, so I am stumped.
vector<string> v1;
v1.resize(2);
v1.insert(v1.begin() + 1, "world");
v1.insert(v1.begin() + 0, "world");
cout << v1.at(1) << endl;
Don’t give up, it’s easier than that
vector::insertis for when you want to add items to your vector, Not when you want to replace ones that are already there,vector::insertchanges the size of the vector in other words.