M
Minkoo Seo
Hi list.
I'd like to print a line "[A BC D EF]" given a vector<string>
containing
"A", "BC", "D", "EF".
The following code is what I've written for this purpose:
#include <iostream>
#include <vector>
#include <iterator>
#include <sstream>
using namespace std;
int main()
{
vector<string> phonemes;
phonemes.push_back("A");
phonemes.push_back("BC");
phonemes.push_back("D");
phonemes.push_back("EF");
ostringstream s;
copy(phonemes.begin(), phonemes.end(),
ostream_iterator<string>(s, " "));
cout << "[" << s.str() << "]" << endl;
return EXIT_SUCCESS;
}
And this prints:
[A BC D EF ]
Please note the unnecessary space placed between "EF" and "]". How can
I modify
this code so that I can get [A BC D EF] in elegant way?
Sincerely,
Minkoo Seo
I'd like to print a line "[A BC D EF]" given a vector<string>
containing
"A", "BC", "D", "EF".
The following code is what I've written for this purpose:
#include <iostream>
#include <vector>
#include <iterator>
#include <sstream>
using namespace std;
int main()
{
vector<string> phonemes;
phonemes.push_back("A");
phonemes.push_back("BC");
phonemes.push_back("D");
phonemes.push_back("EF");
ostringstream s;
copy(phonemes.begin(), phonemes.end(),
ostream_iterator<string>(s, " "));
cout << "[" << s.str() << "]" << endl;
return EXIT_SUCCESS;
}
And this prints:
[A BC D EF ]
Please note the unnecessary space placed between "EF" and "]". How can
I modify
this code so that I can get [A BC D EF] in elegant way?
Sincerely,
Minkoo Seo