Here is my code. I tried to print the content of a vector with a comma after each element as the separator. How can I delete the comma after the last element then?
#include <iostream>
#include <vector>
#include <string>
using namespace std;
void printShoppingList(vector<string> s)
{
for (auto i = s.begin(); i != s.end(); ++i) //iterate vector from start to end
cout<< *i<<", "; //print each item from vector
}
cuz for now my output is like
Items: eggs, milk, sugar, chocolate, flour,
with a comma at the end.
Please help to delete the comma at the end of the output.