I am making a programme in turbo C++ which requires input and output to a file as well as retrieving the file data for later use.
fstream file("playlist.txt",ios::in|ios::app);
this is what I use but everytime i close the programme and run it again, all the previous contents get wiped. I thought ios::app “Sets the stream’s position indicator to the end of the stream before each output operation”.
I tried ios::nocreate also, but to no effect.
You should have
fstream::outtoo:Then you can move file pointer to end of file.
inandappcan’t be used together: you need to open for R/W becauseappimplies you won’t read.