Is it ok to ask quickest way to move to EOF?

What is the quickest way to move to the end of the file?

Is it ok to ask this and is there any one correct answer for this?

I think of some ways....
I think of some ways....

What ways have you thought of??

Andy
the way to move the read/write marker to of when you read a binary file ..the normal c++ way?

There can also be a system call to read to end of file?

It depends.

If you wish to make the file larger, then you simply seek to EOF and start writing.

If you wish to make the file smaller, then things get hairy. Most systems have an OS API function that will truncate a file to a smaller size. If not, or if you wish to do it in pure C/C++, you will have to read the entire file into memory, close the file, reopen it as REWRITE, and write out only as many bytes of the file you wish to keep.

Hope this helps.
Topic archived. No new replies allowed.