void readfile(string str, vector <int> &v)
{
ifstream inputFile;
int num;
inputFile.open(str.c_str());
if (inputFile)
{
while (inputFile >> num)
{
v.push_back(num);
}
}
else
{
cout << "Can not open the file" << endl;
}
inputFile.close();
inputFile.clear();////
}
想用readfile函数读多次文件存储到vector里,为什么只有第一个文件可以读,后面的都不行
readfile(filename_ori, ori_vect);
readfile(filename_first, first_vect);
readfile(filename_second, second_vect);
readfile(filename_third, third_vect);