How to pause in C?

后端 未结 10 865
清歌不尽
清歌不尽 2020-12-05 18:11

I am a beginner of C. I run the C program, but the window closes too fast before I can see anything. How can I pause the window?

10条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-05 18:50

    If you want to just delay the closing of the window without having to actually press a button (getchar() method), you can simply use the sleep() method; it takes the amount of seconds you want to sleep as an argument.

    #include 
    // your code here
    sleep(3); // sleep for 3 seconds
    

    References: sleep() manual

提交回复
热议问题