1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Copy an .exe to a new .exe file using C/C++

Discussion in 'C++' started by Avenger625, Feb 1, 2011.

  1. Avenger625

    Avenger625 New Member

    Let there be an executable file say, t1.exe. If I run t1.exe then it shall copy itself to a new executable file say t2.exe.


    #include <stdio.h>
    #include <stdlib.h>
    #include <conio.h>

    void main()
    FILE *fp,*tp;
    unsigned long int t=0;
    unsigned long int pos=ftell(fp);

    printf("End of t1");

    t2.exe is created but when I run this it says "t2 has stopped working." I'm using Windows 7(Home Basic) 64bit. The program is compiled with Borland C++ V. 5.02.

    And amazingly t1.exe and t2.exe has exactly same file size(in bytes) but still t1.exe works but t2.exe doesn't......don't understand why...??!!

    Please reply fast!!! It's URGENT....!!!!
  2. poornaMoksha

    poornaMoksha New Member

  3. alpha34

    alpha34 New Member

    borland c++ or any c++ compiler for instance which uses DOS mode to compile and run will not work on windows 7 coz windows 7 now doesn't support DOS properly u need to switch to Dev cpp version for using c or c++ program compilation and running....

Share This Page