Pause screen at program completion in C

前端 未结 7 536
名媛妹妹
名媛妹妹 2020-12-17 06:00

I want to be able to do something along the lines of Press any key to exit at program completion, but have no been able to figure out how to.

When I run

7条回答
  •  太阳男子
    2020-12-17 06:27

    Depending on your need and platform, you may use getch() (or _getch()), or ultimately getchar().

    The problem with getchar() is that it requires the user to press "enter". The advantage with getchar() is that it is standard and cross-platform.

    getch() get all the other property : it just needs a key to be pressed, no display, no "enter" needed. But it's non standard, so support varies depending on platform.

    Alternatively, for windows only, there is also :

    system("pause");
    

提交回复
热议问题