This is a probably an embarasing question as no doubt the answer is blindingly obvious.
I\'ve used Visual Studio for years, but this is the first time I\'ve done any
Visual Studio 2015, with imports. Because I hate when code examples don't give the needed imports.
#include <iostream>;
int main()
{
getchar();
return 0;
}
You can also use this option
#include <conio.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main() {
.
.
.
getch();
return 0;
}
If you run without debugging (Ctrl+F5) then by default it prompts your to press return to close the window. If you want to use the debugger, you should put a breakpoint on the last line.
Right click on your project
Properties > Configuration Properties > Linker > System
Select Console (/SUBSYSTEM:CONSOLE) in SubSystem
option or you can just type Console in the text field!
Now try it...it should work
Goto Debug Menu->Press StartWithoutDebugging
In my case, i experienced this when i created an Empty C++ project on VS 2017 community edition. You will need to set the Subsystem to "Console (/SUBSYSTEM:CONSOLE)" under Configuration Properties.