+ 2
How to make the console not turn off immeidately
I made a simple calculator and then compiled it.When i open the exe file.It closes immeidately after displaying the result.Is there a way to pause it after it displays the result?
5 ответов
+ 1
Pretty simple, put the following at the end of your c++ code:
std::getchar();
Since the console awayts a character, the console wont close until you're pressing any key.
Oh and don't forget to #include <cstdio>
+ 1
Umm maybe put... return 0; at the end of the program?
0
if visual studio press CTRL+F5
0
simple, if for simple use, put the code in an infinite loop, since it will always be true it will continue afterwards
0
Try "getchar", it will hold the console screen until next key stroke.
else
you can put the calculator code in a loop where in the end users are supposed to choose if they want to quit or calculate more.
All the best.