当调用 writeToFile 函数时,我想在文件上写一个带有字符串的新行。如果不清除前一行或整个 txt,这可能吗?
void writeToFile(string str) {
ofstream fileToWrite;
fileToWrite.open("C:/Users/Lucas/Documents/apps/resultado.txt");
if(fileToWrite.good()) {
//write the new line without clearing the txt
//fileToWrite << str won't work for this reason
}
fileToWrite.close();
}