I'm trying to get a function to use and add to an fstream, but it doesn't seem to work. Here's what I've got so far:
1 2 3 4 5 6 7
void append_log() {
fstream out(logfile.c_str(), ios::out | ios::app);
out << "info added to stream";
add_to_stream(out);
out << "\n";
out.close();
}
where the add_to_stream function looks like this:
1 2 3
void add_to_stream(fstream & out) {
out << "adding some text";
}
yet for some reason this only adds "info added to stream:" but doesn't add the "adding some text". I have no idea where I'm going wrong so it'd be great to get some feedback!
hamsterman, without ausairman's main routine, I mistakingly thought that he was callin add_to stream() outside of append_log() (which wouldn't work.) My bad!
hamsterman, that snippet ran fine. I did some looking and it turns out I had a booboo elsewhere that was causing my add_to_stream equivalent function not to add to the stream. Thanks for the help :)