problem with my first C++ program

I am new to C++. I did the Hello World code in MS visual C++ 2008 ...when I select execute..the compiler execute the program..it supposes to appear a window..it appears..bt a moment its gone!!! I rewrote the code..compiled several times..but still having the same problem...The window suppose to appear until I press any button to continue... Plz someone help me
If open a console and then run the program it should stay open, otherwise it closes upon completion. You can add cin.get(); for it to wait for user input, or system("PAUSE"); if using windows to wait for any key to be presses, but I'm sure that if I say nothing someone will tell you not to use that.

Also, with VS, if you run it with Debug > start without debugging, it should automatically pause
Last edited on
console programs do that put either a do while or while loop or even a long counting for loop to see the display. best bet is the do while loop.
1
2
3
4
5
6
7
8
9
 
char quit;
do 
{
   cout<<"Hello World"<<"\n";
   cout <<" press Q or q to quit"
   cin>>quit;
}while (quit !="Q"|quit != "q");

That will keep the input on the screen til you wan to quit.

i forgot about that option.
Last edited on
Also...you used '|' instead of '||'...you want the logical or (||).
Tx for u'r replies. But the video I saw of that tutorial had no such a code lyk tht...and their window didn't disappear like mine!!!!

So whats the point here..I use same type software to compile the code lyk them..but didn't get the result lyk them...
I fixed it........tx guyz :)
I've the same problem, how did you manage it?
meant || didn't notice i didn't include the second |
Topic archived. No new replies allowed.