I have this function:
How can I make it output at the end of the file, rather than overwriting it?Code:void addmovie() { char string[50] = {'\0'}; ofstream outFile("C:\\test.txt", ios::out); if (!outFile) { cout << "File could not be opened!" << endl; exit(0); } cout << "String: "; cin.ignore(); cin.getline(string, 50, '\n'); //outFile.seekp(outFile.eof()); outFile << string; outFile << '\n'; }
I thought about reading the file, and adding to it, then writing it back...but is there any other way?




Reply With Quote