problem in a program

// my first program in C++

#include <iostream>
using namespace std;

int main ()
{
cout << "Hello World!";
return 0;
}

this program is not showing the result at microsoft visual C++ express .
Can anyone tell me the correct program
what is this ?
dont listen to that like i said just use system pause before the return 0
@EricM260

Please do NOT tell others what to do. If you really want to learn C/C++ language, then try to learn new things instead of using what you know there. Please read the posts in that URL and find out why system("pause") is not as good as the other ways they mentioned there!
closed account (z05DSL3A)
Masiht,

There is nothing wrong with your code. The 'problem' that you are seeing is that windows generally closes command line windows once the program running in them exits.

If you select Start Without Debugging from the Debug menu of express, the window id held open for you to see the result (there will be a Press any key to continue message tagged on to the end of your output).

Some people put a system("pause") call in to the program just before the main function returns. The system() call basically asks the operating system to run a command/program, in this case a a command design for batch files, and waits for this to happen before the program continues.

The link that Helios posted is a long discussion about this, why it is not considered good practice, and suggestions for other methods of achieving the same this. It it worth reading.
If system ("pause"); is not considered good practise to run the prgram with debugging,Then How can I run the program with a better practise ?
Last edited on
closed account (z05DSL3A)
Read the link that Helios posted!!!
Topic archived. No new replies allowed.