Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Having trouble running C++ compiler

  1. Jun 1, 2008 #1
    The type of compiler I am using is Dev-C++. I have no problem compiling my code and my compiler has generated no errors. However , when I try to run my code, The command prompt for like a nano-second and disappears and I have no idea of how to retreive it .
    Last edited: Jun 1, 2008
  2. jcsd
  3. Jun 1, 2008 #2


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    The problem with computers is that they do exactly what you tell them to do. :smile: It sounds like you either need to run your program from a persistent command prompt, or change your program so that it doesn't finish immediately upon printing the output you want to see.
  4. Jun 1, 2008 #3
    It would help if you could post some code example which do not work for you, otherwise it is not very easy to help you.
  5. Jun 1, 2008 #4
    Check if there are any spaces in the names of any of the folders/subfolders/files that you are using for the compiler and name of your program file...

    e.g. should be



    C:\\My Documents\the compiler\test program.exe

    (I also use Dev-C++, if I have any spaces in the names, it does exactly what you say yours does)
    Last edited: Jun 1, 2008
  6. Jun 1, 2008 #5
    With most newer IDE environments, when you execute a terminal program in windows, as soon as the program is terminated, the terminal window will close. There are ways to alter this behavior, but usually the best course of action is to open a persistent terminal window, and execute your program from there.

    For example, go to "RUN" and type: cmd.

    Then navigate to the directory where the program is compiled, for instance cd C:\users\administrator\documents\debug.

    Then, you simply execute the program by invoking its name, for example, C:\helloworld.exe.

    Your other option is to put some kind of pause statement at the end of your program, to allow you to view the output.

    For instance:

    int End1;
    cin >> End1;
    return 0;

    Then, the program will wait for you to enter an integer, giving you time to view the programs output before the terminal window is closed.
  7. Jun 1, 2008 #6

    I know it sounds weird, but it worked for me.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook