C++ How do to have the program sleep for a few seconds???

+3 votes
asked May 14 by (150 points)

I tried doing Sleep(3000) but it doesn't work and #include<windows.h> isn't allowed

2 Answers

0 votes
answered May 15 by (3,240 points)
OnlineGDB is hosted on Linux not windows so need to use #include <unistd.h>, which is the Linux header file equivalent to windows.h
0 votes
answered May 16 by (180 points)

You could use while and/or for loop. You could even use <time.h> to propperly check time per clock or seconds passed. An example, is to create a function containing this instructions.

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...