delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/10/17:46:35

From: Mark Favata <favata AT epix DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Error Writing to File
Date: Wed, 10 Dec 1997 15:29:12 -0500
Organization: Scorpion Industries
Lines: 24
Message-ID: <348EFB98.25F8@epix.net>
NNTP-Posting-Host: svcr-84ppp163.epix.net
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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?

This is like the code I am using:

if((in = fopen(argv[1], "rb+")) == NULL)
{
 printf("Error opening output file.\n");
 exit(-1);
}

while(!feof(in))
{
 fprintf(in, "0");
}

fclose(in);

Mark Favata
favata AT epix DOT net

- Raw text -


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