Hi, i want to read some lines to an output text file in a loop. My problem is, that i want to start clearing the text file and then append to it in a loop. At the moment i use:
ofstream file;
file.clear();
file.open("book.txt", ios::app);
for (map<string,Person>::const_iterator it = adrbook.begin();
it != adrbook.end(); ++it) {
file.open("book.txt");
string name = it -> second.get_Name();
file << name;
}
file.close();
my problem is, that it does not clear the content of the file, so i am just appending on a file with content from previous runs.