Pause screen at program completion in C

前端 未结 7 515
名媛妹妹
名媛妹妹 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:36

    To do this quick hack, the most common two options are:

    /* Windows only */
    #include 
    
    system("pause");
    

    and

    /* Cross platform */
    #include 
    
    printf("Press enter to continue...\n");
    getchar();
    

    I suggest the latter method, though the first method really triggers on "any" key while the bottom one only triggers on enter.

提交回复
热议问题