how to delay an output ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

how to delay an output ?

which function or header file is used to delay the output for few seconds ?

23rd Jul 2016, 8:45 AM
Karan Luther
Karan Luther - avatar
4 Answers
+ 2
For Windows OS, this will work: #include <windows.h> Sleep(x); Where x = # of milliseconds, where 1000ms = 1s
23rd Jul 2016, 9:43 AM
Cohen Creber
Cohen Creber - avatar
+ 1
dos.h and time.h
23rd Jul 2016, 8:51 AM
Darsh Shah
Darsh Shah - avatar
+ 1
this_thread::wait_for(chrono::seconds(1)); This is going to wait exactly one second. chrono is in library chrono and this_thread in library thread (i think).
23rd Jul 2016, 10:00 AM
Ternary
0
@Ternary: Great example but unfortunately that's C++11 which is not being taught here. People here are using SoloLearns compiler and Borlands Turbo C++. Made my very first steps in C++, that's how old and obsolete Turbo C++ is now :-)
23rd Jul 2016, 11:01 AM
Stefan
Stefan - avatar