I am trying to partially truncate (or shorten) an existing file, using fstream. I have tried writing an EOF character, but this seems to do nothing.
Any help would be appreciated…
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I don’t think you can. There are many functions for moving “up and down” the wrapper hierarchy for
HANDLE<->int<->FILE *, at least on Windows, but there is no “proper” to extract theFILE *from an iostreams object (if indeed it is even implemented with one).You may find this question to be of assistance.
Personally I would strongly recommend steering clear of iostreams, they’re poorly designed, heavily C++, and nasty to look at. Take a look at Boost’s iostreams, or wrap stdio.h if you need to use classes.
The relevant function for stdio is ftruncate().