C sleep function not working

前端 未结 3 1558
执念已碎
执念已碎 2021-01-04 20:22

When including the sleep function from unistd.h the program hangs indefinitely:

#include 
#include 

int main()
{         


        
3条回答
  •  失恋的感觉
    2021-01-04 20:51

    Are you on a Windows computer? If so, include in your program, and to pause the program, write

    Sleep(time_in_milliseconds)
    

    where in your case time_in_milliseconds should be 2000.

    On the other hand, if you're on a UNIX based computer, the code looks fine (no need for ).

提交回复
热议问题