Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Linux by (18.4k points)

I knew that POSIX sleep(x) function makes this program sleep for x seconds. Is there any other function to make any program sleep for x milliseconds in C++?

1 Answer

0 votes
by (36.8k points)

Note that there is no regular C API for milliseconds, so (on Unix) you need to settle for usleep, which accepts microseconds:

#include <unistd.h>

unsigned int microseconds;

...

usleep(microseconds);

To know about Linux join the Linux training

 

Do check out the video

 

Related questions

0 votes
1 answer
asked Dec 13, 2020 in Linux by blackindya (18.4k points)
0 votes
1 answer
0 votes
1 answer
asked Feb 2, 2021 in Linux by blackindya (18.4k points)
0 votes
1 answer
asked Jan 24, 2021 in Linux by dev_sk2311 (45k points)
0 votes
1 answer
asked Jan 12, 2021 in Linux by blackindya (18.4k points)

Browse Categories

...