www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/12/12/19:46:20

Date: Mon, 12 Dec 94 13:10:42 -0500
From: dj AT stealth DOT ctron DOT com (DJ Delorie)
To: IBBT0 AT cc DOT uab DOT es
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: Help about truncating files

DOS says that if you write zero bytes, the file is truncated where the
pointer is.  With FILE* streams, this is tricky (because of the
caching), but what you can do is this:

	fflush(f);
	lseek(fileno(f), POS, 0);
	write(fileno(f), 0, 0);

You should close the file ASAP after this - I've seen DOS get confused
when you use this feature.


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019