Sleep function in Windows, using C

前端 未结 4 1008
一生所求
一生所求 2020-11-28 11:42

I need to sleep my program in Windows. What header file has the sleep function?

4条回答
  •  清歌不尽
    2020-11-28 12:26

    Use:

    #include 
    
    Sleep(sometime_in_millisecs); // Note uppercase S
    

    And here's a small example that compiles with MinGW and does what it says on the tin:

    #include 
    #include 
    
    int main() {
        printf( "starting to sleep...\n" );
        Sleep(3000); // Sleep three seconds
        printf("sleep ended\n");
    }
    

提交回复
热议问题