Re: how to add a new line with text and the end of a file if the file alre

Posted 06 February 2011 - 03:01 PM

ok so i was able to write to the file i was reading from but when i a got to write the info i wanted to, ma previous info got erased. how can i write to the file without erasing my previous data . thanks

Re: how to add a new line with text and the end of a file if the file alre

Posted 06 February 2011 - 06:49 PM

elninox91, on 06 February 2011 - 05:18 PM, said:

the

1
dbfile.open("myinput.txt",ios::app);

adds the info to the file, however it adds it like next to last letter on the last word; it doesnt add the info in a new line . what do i need to include so tat the info goes in a new line? thanks
got it !!!! thanks guys.... now i just need to erase a line from the file . for instance :
lets say i got this
1234 5000
4567 8446y
7812 500
4444 200
7777 600
and lets say i want to delete a line from the middle, how would i do it? thanks.

You could read your data file into a vector of struct ...
Then update that vector as you wish ...
Then rewrite the data in the vector container over top the old data file.
But may be better to use list instead of vector as a container if you want to do deleted easily.