How do you add a timed delay to a C++ program?

后端 未结 14 2160
情话喂你
情话喂你 2020-11-28 02:11

I am trying to add a timed delay in a C++ program, and was wondering if anyone has any suggestions on what I can try or information I can look at?

I wish I had more

14条回答
  •  佛祖请我去吃肉
    2020-11-28 02:34

    In Win32:

    #include
    Sleep(milliseconds);
    

    In Unix:

    #include
    unsigned int microsecond = 1000000;
    usleep(3 * microsecond);//sleeps for 3 second
    

    sleep() only takes a number of seconds which is often too long.

提交回复
热议问题