some IDEs support two types of execution, one that closes after finish, and a debug mode that pauses the console before the main returns.
if your IDE support such mode, you can use it, otherwise check this: