Monday, June 25, 2012

How to Create a Self Destructing Program in C

Leave a Comment

Create a Self Destructing Program in C

Create a Self Destructing Program in C

 A C program on successful compilation makes a .exe file which is being used for the execution of the Program .This exe file can be directly used by anyone to run the program without looking into the script i.e the coding done for the program.

Using the method described in this Post , you would be able to create a Self Destructing Program in C. A self destructing program in C deletes its .exe file after execution.

Just type in the following code in Turbo C/C++ 

  • #include < stdio.h>
  • #include < conio.h>
  • #include < dos.h>
  • void main()
  • {
  • printf(" This is a Self Destructing Program");
  • getch();
  • remove(_argv[0]);
  • }

remove(_argr[0])  means array of pointers to command line arguments.

Q>How does it work?

Ans. Type in the source code into the compiler and compile the code using Alt + F9. And then press F9.

This Procedure will generate a .exe file in the Current directory i.e the Bin folder.
On execution of file , the .exe file will delete itself.

Have fun , Enjoy this trick .

Kuanl Ganglani


C Program Without Main Function

 How to play Music in C ?

Play Awesome Games while searching on Google



If You Enjoyed This, Take 5 Seconds To Share It

About Author:

Kunal Ganglani: I am a Passionate Blogger, a Computer Science Engineer, Internet Marketer and an Entrepreneur at heart. I am the founder and Admin at KGTricks.

Connect With Me @ | Facebook


Post a Comment

Related Posts Plugin for WordPress, Blogger...