How do I SHORTEN a file without rewriting it?

Bob Stout Bob.Stout at p6.f506.n106.z1.fidonet.org
Mon Oct 29 17:03:09 AEST 1990


  Since the Unix folks were quick to answer with environment-specific answers 
to an inherently non-portable question, I can feel free to tell you how to do 
it under MS-DOS since this is apparently what you were looking for.

  Use a DOS low-level (file handle) open call to open the file. Then, still 
using the low-level DOS services, seek to the position where you wish to 
truncate the file, then perform a DOS write of zero bytes. The same technique 
can be used to extend a file by seeking to paosition past its present end.

  Several DOS C compilers already contain non_ANSI functions in their standard 
libraries to do this - look for chsize(). Hope this helps...
 



More information about the Comp.lang.c mailing list