I have looked around at that common issue beginners tend to ask a lot - "How do I stop the console closing down?", finding many ideas. The simplest always seems to be something along the lines of "use getchar(); or std::cin.get(); just before return", which used to work for me on my old laptop.
Now that I am using a powerful PC that I built, for some reason I am having to put these lines at least twice before it prevents closing. Is there something I am completely missing that I have forgotten from when I used the laptop?
Here is a really simple example of what I have used at the end of the main function:
1 2 3
|
std::cout << "\n\n\nPress [enter] to exit.";
getchar();
return 0;
|
The above will not prevent closure, but the following will (enter still only has to be pressed once):
1 2 3 4
|
std::cout << "\n\n\nPress <enter> to exit.";
getchar();
getchar();
return 0;
|
I am using VS 2013 if that makes any difference to anything.
For people who will say "use CTRL-F5", I was hoping to have the same effect in the actual application.
Apologies for any blatant newby mistakes, and thanks in advance!