Delete chars in a file stream

B

Bernie

Hi

How can I remove/delete the last n characters from a fstream object?

Thanks
Bernie
 
J

James Kanze

How can I remove/delete the last n characters from a fstream object?

You can't.

First of all, of course, an fstream doesn't contain any
characters; it is only an interface to an external file which
contains the characters. But there's no standard way of
truncating a file, either (and some OS's don't support it at
all). The usual solution is to copy the file to a new file,
without copying what shouldn't be copied. There will often be
an OS specific means of truncating the file as well, but you
can't use it on an fstream; you'll have to check with your OS
documentation for more information there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top