程序代码:
#include <iostream>
#include <fstream>
#include <iterator>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int deal_string(vector<string> &nVec)
{
vector<string>::size_type size = 0;
for (; size!=nVec.size(); ++size)
{
nVec[size] = nVec[size].substr(0, nVec[size].find('}'));
size_t i = nVec[size].find('{');
nVec[size].erase(i,1);
}
return 0;
}
int main()
{
ifstream in("test.txt");
vector<string> nVec;
string nStr;
cout << in.rdbuf() << endl;
in.seekg(0, ios::beg);
copy(istream_iterator<string>(in),
istream_iterator<string>(),
back_inserter(nVec));
deal_string(nVec);
copy(nVec.begin(), nVec.end(),
ostream_iterator<string>(cout, "\n"));
return 0;
}