Sleep function in C++

后端 未结 7 1648
情书的邮戳
情书的邮戳 2020-11-27 03:27

Is there a function like Sleep(time); that pauses the program for X milliseconds, but in C++?

Which header should I add and what is the function\'s sign

7条回答
  •  无人及你
    2020-11-27 03:29

    Just use it...

    Firstly include the unistd.h header file, #include, and use this function for pausing your program execution for desired number of seconds:

    sleep(x);
    

    x can take any value in seconds.

    If you want to pause the program for 5 seconds it is like this:

    sleep(5);
    

    It is correct and I use it frequently.

    It is valid for C and C++.

提交回复
热议问题