I want to add a element such as a space "" inside a vector<string> myvector. For example:
1 2 3 4 5
myvector[0]+myvector.insert("")+myvector[1]+...+myvector.insert("")+myvector[i]
//I cannot do this individually because myvector.size() will not be constant.
//I want a loop it so it stops once it reaches the last string and then prints out the result
If there is way to do this in vector please let me know! Also, is it easier to do it if I convert the elements to a string and then add spaces. I tried both but I just couldn't write it in a code.
I don't know that building a string is necessary, but:
1 2 3 4 5 6
// assumes: myvector.empty() is false.
auto s = myvector.front();
for (auto i = std::size_t {1}; i < myvector.size(); ++i)
s += ' ' + myvector[i];
std::cout << s << '\n' ;