Date: Fri, 12 Dec 1997 11:54:34 +0800 (PST) From: Orlando Andico To: Mark Favata cc: djgpp AT delorie DOT com Subject: Re: Error Writing to File In-Reply-To: <348EFB98.25F8@epix.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Wed, 10 Dec 1997, Mark Favata wrote: > Can someone please help me. I am writing an encryption program and > want to add a file wipe feature. I plan on overwriting the file with 1, > then 2, etc. The problem is, it keeps writing past the eof mark. > Within about 2 seconds it has already written 2 megs to the file. My > code doesn't seem to stop for the EOF. Can you tell me what is wrong > with my code? .. better idea: use stat(2) to determine the file's length (read the Info docs for details) so you don't have to rely on feof() or similar. Also, if you know the length in advance, you can fwrite() your buffer to the file in 8K chunks, which is very fast.