Date: Thu, 15 May 1997 10:47:57 +0200 (MET DST) From: Wojciech Piechowski To: Jean-Gael Gricourt cc: djgpp AT delorie DOT com Subject: Re: remove() don't work ? In-Reply-To: <01bc5ede$42f78680$eb173ccc@jordan> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk 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 > > 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.