I am running Dev C++ 4.9.9.2 and running OS Windows 7 RC
I am trying to get a command prompt show the string "C++ is power programming."
The problem is that it works. The command prompt window show up and it says those exact words. Then it dissappears in less than a second. Here is the code, also i tried another string with new code but that did not work either:
/
This is a simple C++ program
Call this file Sample.cpp/
include <iostream>
using namespace std;
// A C++ program begins at main().
int main()
{
cout << "C++ is power programming.";
return 0;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
As for all programs running under Windows, when the program terminates, its window is closed by the OS. You would not want it any other way, otherwise you'd have a screen full of zombie windows!
But despite this normal behaviour people always seem to be surprised when it happens to their own code! This miscomprehension is so common in fact, it is dealt with in the "PLEASE READ BEFORE POSTING A QUESTION" thread of this very forum.
Now your phrase "I am trying to get a command prompt show..." is very telling. The 'command prompt' specifically refers to the 'ready for input' indicator in programs such as cmd.exe (the Windows command shell). cmd.exe is an example of a 'console mode application'. Your program is also a 'console mode' program, and nothing to do with "command prompt".
Incidentally, if you did run your program from within cmd.exe, it runs as a child of cmd.exe and so the window will not close until cmd.exe terminates, which you have to do by taking deliberate action such as the 'exit' command. There's a clue to your solution - write your code so that some deliberate action has to be taken to terminate.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am running Dev C++ 4.9.9.2 and running OS Windows 7 RC
I am trying to get a command prompt show the string "C++ is power programming."
The problem is that it works. The command prompt window show up and it says those exact words. Then it dissappears in less than a second. Here is the code, also i tried another string with new code but that did not work either:
/
This is a simple C++ program
Call this file Sample.cpp/
include <iostream>
using namespace std;
// A C++ program begins at main().
int main()
{
cout << "C++ is power programming.";
As for all programs running under Windows, when the program terminates, its window is closed by the OS. You would not want it any other way, otherwise you'd have a screen full of zombie windows!
But despite this normal behaviour people always seem to be surprised when it happens to their own code! This miscomprehension is so common in fact, it is dealt with in the "PLEASE READ BEFORE POSTING A QUESTION" thread of this very forum.
Now your phrase "I am trying to get a command prompt show..." is very telling. The 'command prompt' specifically refers to the 'ready for input' indicator in programs such as cmd.exe (the Windows command shell). cmd.exe is an example of a 'console mode application'. Your program is also a 'console mode' program, and nothing to do with "command prompt".
Incidentally, if you did run your program from within cmd.exe, it runs as a child of cmd.exe and so the window will not close until cmd.exe terminates, which you have to do by taking deliberate action such as the 'exit' command. There's a clue to your solution - write your code so that some deliberate action has to be taken to terminate.
Clifford