wpfwannabe
wpfwannabe

Reputation: 14867

Truncate file open with fopen

It's been a long time since I've had to use this... How can I can truncate the file open with fopen() at the current file pointer?

I am on Windows if there is no universal solution.

Upvotes: 1

Views: 1544

Answers (1)

Milan Babuškov
Milan Babuškov

Reputation: 61138

Since you're on Windows, use this:

_chsize( fileno(f), size);

Or the 64bit version:

_chsize_s(_fileno(f), size);

Upvotes: 3

Related Questions