C++ beginner, execution window disappears quickly

前端 未结 7 1811
我寻月下人不归
我寻月下人不归 2020-12-11 11:50

I am a beginner in C++ and I was trying to write a program that finds the average of two numbers, but when I run the program, the window disappears without allowing me to se

7条回答
  •  再見小時候
    2020-12-11 12:31

    I always hated that...I always find the easiest to be system("pause"); right before you return, but that's not a portable solution (cin.get is though). There are many other ways as well, some of which are mentioned in the link below.

    http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvc/thread/1555ce45-8313-4669-a31e-b95b5d28c787

    Edit: system("pause"); is terrible, should never be used, and may or may not end life on this planet as we know it, even if by a beginner in a project called 'Hello'. Using system("pause") is expensive and dangerous, and if you use it, you'll never see anyone you love again. Don't do it. Use cin.get or something else.

提交回复
热议问题