Mail Archives: djgpp/1997/05/15/05:03:11
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 -