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.
Well, at least he's polite. Here, I'll even help you: Sepples (C++) is a terrible language and you should start avoiding it immediately. Learn Scheme (using a book called Structure And Interpretation of Computer Programs) or at least Python. If you want to learn a low-level language, learn C and/or assembly; they're both good for giving you an idea of what's going on. Last but not least, read the fucking manuals and APIs. Spend at least one hour Googling intelligently before creating a post anywhere about your question. Someday you may become a good programmer, young padawan.
>>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.
Can't really choose my own language, I'm studying it at my university, they decided that we should learn an industry popular language in our second year
>>7
Well, here we have it /prog/; someone who already knows STHICKP, yet cannot program. I hereby put forward that we no longer tell people to read said aforementioned book; it is clearly ineffective!