the stream save_file is not in scope. You have to do it this way.
Code:
void save_file(string filename, vector<string>to_save, int truncate) {
ofstream save_file;
if(truncate == 0) {
save_file.open(filename.c_str(),ios::trunc);
}
else {
save_file.open(filename.c_str(),ios::app);
}
string write;
for(int x=0; x<to_save.size(); x++) {
write = to_save[x];
save_file << write << "\n";
}
// save_file.close(); // not necessary the destructor will close the stream
// return; // not necessary
}
Kurt
EDIT: It would be more efficient if you would pass the vector to_save by reference.
Like this
Code:
void save_file(string filename, vector<string> & to_save, int truncate)