I would like to use either fstream or preferably QFile to remove the contents of a file after a specific position (that’s not the beginning or the end of the file). So I first jump to that position with QFile::seek(long) or equivalent in constant time, and then I would like to remove the remainder of the content, also in constant time. What approach do you recommend?
I would like to use either fstream or preferably QFile to remove the contents
Share
You can use
QFile::resizeto resize the file to the size you want. I bet it usestruncatebehind the scenes (see Andrew’s post).