Problem:Change Fillvector.cpp so that it concatenates all the elements in the vector into a single string before printing it out, but don’t try to add line numbering.
问题:修改Fillvector.cpp,使其在打印出vector内全部元素前,将其全部元素合并为一个字串,但是不需要给每行编号。
//: C02:Fillvector.cpp
// Copy an entire file into a vector of string
#include<string>
#include<iostream>
#include<fstream>
#include<vector>
using namespace std;
void main(){
vector<string>v;
vector<string>u;
ifstream in("2.txt");
string line;
string s;
while(getline(in,line))
v.push_back(line); // Add the line to the end
for(int i=0;i<v.size();i++)
s+=v[i];
cout<<s<<endl;
} ///:~