I am trying to use C++ vector instead of C arrays, but I have some problems. This is my code:
size_t i;
//Filter save files
for (i = 0; i != files.size(); i++){
cout << files.at(i).find(FILE_HEAD) << ' ' << files.at(i) << endl;
if ((files.at(i).find(FILE_HEAD) != 0)){
files.erase(files.begin() + i);
}
}
cout << "Found files:\n";
for (i = 0; i != files.size(); i++){
cout << i << " - " << files.at(i) << endl;
}
files
is a std::vector<std::string>
and I want to remove all elements which not contain FILE_HEAD
. But this doesn't work properly, in my test file.size()
is 14 but it goes in for only 7 times. Can anyone help me? Thank you!