delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/15/05:03:11

Date: Thu, 15 May 1997 10:47:57 +0200 (MET DST)
From: Wojciech Piechowski <voyt AT delta DOT ds2 DOT pg DOT gda DOT pl>
To: Jean-Gael Gricourt <jean-gael DOT gricourt AT snet DOT net>
cc: djgpp AT delorie DOT com
Subject: Re: remove() don't work ?
In-Reply-To: <01bc5ede$42f78680$eb173ccc@jordan>
Message-ID: <Pine.GSO.3.96.970515104524.22499A-100000@delta.ds2.pg.gda.pl>
MIME-Version: 1.0


On 12 May 1997, Jean-Gael Gricourt wrote:

> 
> Hi,
> 
> Please, someone tell me why It is impossible to erase a file with
> 'remove()'  :
> 
> Note: I runned it under Win 95 inside a dos box.
> 
> -------------------------------------------------
> #include <stdio.h>
> 
> int main()
> {
>  FILE *tmp=fopen("ex.$$$","w");
> 
>  if(tmp==NULL) { perror("fopen");return 1; }
> 
>  fprintf(tmp,"Just a try.");
> 
>  if(remove("ex.$$$")!=0) puts("I can't get ride of this #$?% file ! Why
> ?");
> 
>  fclose(tmp);
> 
>  return 0;
> }
> -------------------------------------------------
> 
> JGG
> 

It seems that you are trying to remove a file which is currently opened
and such operation is forbidden. Put _fclose(tmp)_ before _if(remove..._
and it should work.


- Raw text -


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