How to write a program such that it will delete itself after exectution?

Showing Answers 1 - 7 of 7 Answers

Ashwin

  • Jan 27th, 2006
 

Hi!It works even on windows!!!!!!Ashwin

  Was this answer useful?  Yes

Safir

  • Jan 27th, 2006
 

has anyone tried unlink?

The unlink() system call removes a directory entry. As a side effect this will decrement the link count and, if that goes to zero, will cause the file to be deleted.

int unlink(const char *path);

  Was this answer useful?  Yes

A. Dubey

  • Feb 19th, 2006
 

Hi as another way to implement this program we can use file handling .

  Was this answer useful?  Yes

supriya ahire

  • Aug 1st, 2006
 

Hi all ,

  i have tried this program which successfully works.......

the program is as::

#include<stdio.h>

   int main()

   {     char file[90];

       //accept file name from user which usert to remove.

        printf("Enter filename");

           gets(file);

    if(remove(file)==0)

   printf("%s file successfully removed",file);

else

   printf("not removed");

getch();

return 0;

   }

Thanks & Regards,

Ms.Supriya Ahire

  Was this answer useful?  Yes

harish

  • Sep 17th, 2006
 

#include #include int main(int argc, char * * argv){remove(argv[0]);return EXIT_SUCCESS;}in unix

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions