Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep alive a program in C++?

Tags:

c++

I'm using Visual C++ 2010 Express and I just started learning C++.

So when I want to run this code:

#include <iostream>
using namespace std;

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

It works, but the program exits immediately after I started it, how should I keep the program alive?

like image 249
Adam Halasz Avatar asked Nov 29 '22 11:11

Adam Halasz


1 Answers

In Visual studio you have two options to run a program. There is absolutely no need to modify your code as many other posts are suggesting.

1) Run with debugging. You are probably using this, and to make it stop anywhere, you need to set a breakpoint.

2) Run without debugging. This should leave the console window open, and prompt you to press a key before the window closes.

like image 150
Tim Rupe Avatar answered Dec 09 '22 12:12

Tim Rupe