#include<iostream>
#include<fstream>
#include<vector>
#include<string>
using namespace std;
int main()
{
vector<string> files;
string fileName, s;
cout << "Enter filenames:(Ctr+Z to end)" << endl;
while(cin >> fileName)
files.push_back(fileName);
ifstream input;
vector<string>::const_iterator it = files.begin();
while(it != files.end())
{
input.open(it->c_str());
if(!input)
{
cerr << "error: can not open file:" << *it << endl;
input.clear();
++it;
}
else
{
while(input >> s)
cout << s;
input.close();
input.clear();
++it;
}
}
return 0;
}
C++Primer8.8——vector中一次读取文件内容
最新推荐文章于 2023-02-21 19:58:21 发布