Compiler not taking insertion operator with ofstream.
Code:
void save_file(string filename, vector<string>to_save, int truncate)
{
if(truncate == 0)
{
ofstream save_file(filename.c_str(),ios::trunc);
}
else
{
ofstream save_file(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();
return;
}
I'm assuming I screwed up the syntax somewhere, although it looks alright to me. I tried using .c_str() on write, and also putting it in "'s (so that, like, it'd literally write the word "write" to the file. I'm not sure what THIS was supposed to solve XD), but neither changed the errors.
44 generic_functions.cpp no match for 'operator<<' in 'save_file << write'
Also getting
46 generic_functions.cpp request for member `close' in `save_file', which is of non-class type `void ()(std::string, std::vector<std::string, std::allocator<std::string> >, int)'
Do I need to pass some additional parameters to the ofstream (or fewer?)