Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++ text output file

Name: Anonymous 2010-11-20 18:31

Hey /prog/, I'm learning C++ this year and I need to output a textfile for one of my tasks, to do this, I use this code:

void write_file (string race, int str, int con, int dex, int cha)
{
    fstream char_list ("characters.txt");
    char_list.open("characters.txt");
    char_list << race << "\t"
    << str << "\t"
    << con << "\t"
    << dex << "\t"
    << cha << "\n";
    char_list.close();
}

However, whenever I run the code, it overwrites the file with the new text. So my question is if there is any way to keep the previous contents of the file without manually picking up the text and inserting it after the new bit.

Name: Anonymous 2010-11-20 18:55

You would try The D Programming Language, if you need something Sepples-like that doesn't suck.
But listen to >>5

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List