How to truncate a file under DOS/Windows?
In Unix, there is a C function: truncate (const char *file, size_t length) which calls a system function and truncates the file to the desired size.
That'll be two dollaz please
> I don't have the source for the .lib supplied by cygwin
1. Install Cygwin
In code (sorry).
I had to do this once. SetEndOfFile doesn't do all that truncate does - first you have to get a handle to the file with write access using CreateFile, and then move to the desired offset using SetFilePointer, call SetEndOfFile, and then close the handle. I always wondered if there was a less complicated way.
Write zero bytes to file (Int 21h func 40h).
Fog Creek Home