I'm supposed to create a program to read in word by word into a vector. And print out the words connected with '-'... so if the input was hello world the output would be hello-world
this is the code ive made so far... right now my input can be hello world but my output would be
hello-
world-
i dont want the - after world and i want it printed out on one line... any help would be appreciated.
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
using std::vector;
int main()
{
vector<string>svect;
string word;
while( cin >> word ){
word += '-';
svect.push_back(word);
}
for( int i = 0; i < svect.size(); i++ )
cout << svect[i] << endl;
return 0;
}