In Windows if you just want to truncate the file after you've finished writing then SetEndOfFile() is the way to go for a HANDLE. If you are working with an fd then SetEndOfFile((HANDLE) _get_osfhandle(fd)). _chsize() or _ftruncate() may only support 32 bit arguments on 32 bit compilers. In Unix AFAIK there isn't any "no size" function like SetEndOfFile().