Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Is there anyway to add a millisecond pause in Onlinegdb

0 votes
asked Mar 9, 2018 by rfreeman6100 (150 points)
I know there is a way to do it with windows exclusive libraries but I know Onlinegdb won't allow for use of windows exclusive libraries. I prefer C++ but any of the available languages I can do this in I would like to know.

2 Answers

0 votes
answered Jan 5 by Max Jian (680 points)
reshown Jan 5 by Max Jian
In C++ it does not provide a pause function of its own. You have to use windows to provide the functionality. However, in python you can do time.sleep(3) (Three Seconds) I’m not sure if that is available in online GDB though, since I don’t use python.
commented Jan 6 by Peter Minarik (66,630 points)
Wrong. It does. See my answer.
0 votes
answered Jan 6 by Peter Minarik (66,630 points)

Source: https://stackoverflow.com/questions/158585/how-do-you-add-a-timed-delay-to-a-c-program

#include <chrono>
#include <iostream>
#include <thread>

int main() {
    using namespace std::this_thread;     // sleep_for, sleep_until
    using namespace std::chrono_literals; // ns, us, ms, s, h, etc.
    using std::chrono::system_clock;

    std::cout << "Sleeping for 5 s" << std::endl;
    sleep_for(5s);
    std::cout << "Sleeping for 10 ns" << std::endl;
    sleep_for(10ns);
    std::cout << "Sleeping for 1 ms" << std::endl;
    sleep_until(system_clock::now() + 1ms);
    std::cout << "All done." << std::endl;
}
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.
...