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:50

>>5
I actually learned scheme last year and still have to write my current software project in scheme (although it's called racket now, don't really see why). I'm also learning assembly (for the i386) and C this year.

Half of my first year was actually based on structure and interpretation, still got it lying around my desk.

I'll google more the next time, I spend some time searching the c++ resources network.

>>6

Thanks

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