Question:

How do i get the console window to remain open in Visual C++ 2005?

by Guest62525  |  earlier

0 LIKES UnLike

I am trying to write a program in visual studio C++ 2005. For example lets look at this program.

#include <iostream>

int main()

{

std::cout <<"Hello World!\n";

return 0;

}

When I run the program the console window does not remain open for me to see the output. Does anyone know how i can fix this problem?

 Tags:

   Report

2 ANSWERS


  1. Do as Mike C suggests.

    Alternatively, open a command prompt.  cd to the directory that contains your executable.  Then run it from there.  Window stays open.

    This has the added advantage of letting you redirect the output to a file if you need to put in a lot of debug couts that you want to be able to look at.


  2. Add this line of code in.

    #include &lt;iostream&gt;

    int main()

    {

    std::cout &lt;&lt;&quot;Hello World!\n&quot;;

    system(&quot;pause&quot;);

    return 0;

    }

    Should do the trick you&#039;re looking for.

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.