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]);
- }
Here
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 .
ALSO READ:
0 comments:
Post a Comment