Nov 1, 2014 at 12:58am UTC
How to terminate a c++ program after showing the results in console window.Do not wait for the key stroke.
Last edited on Nov 1, 2014 at 1:28am UTC
Nov 1, 2014 at 1:03am UTC
The program will terminate automatically when you return from the main function.
Nov 1, 2014 at 1:06am UTC
You mean I don't need to anything particular to make it happen.Just return 0 at the end of the main function will be good?
Nov 1, 2014 at 1:20am UTC
I mean in Windows OS,when the results show up in the console window,the program waits for the key stroke to show down the console window.
Is this the case?If so,how to shut it down immediately after the program finished.Do not wait for the key stroke.
I want to know what's the case in Windows OS,because I am a Mac user.
Last edited on Nov 1, 2014 at 1:33am UTC
Nov 1, 2014 at 2:06am UTC
Just as on a Mac, it's not your business to decide what the user wants. If the OS had to open a console window to run your program, it will close it when your program terminates. If the user opened a console window and started your program from it, he'll be totally ticked off of your program closes it.
Hope this helps.
Nov 1, 2014 at 9:38am UTC
The wait thing might be something that your IDE is doing. Try run your program outside the IDE and see if there is a difference.