+ 1

How to NOT print a text suddenly?

Hi! #include <iostream> #include <unistd.h> using namespace std; int main() { cout << 'H'; usleep(100000); cout << 'e'; usleep(100000); cout << 'l'; usleep(100000); cout << 'l'; usleep(100000); cout << 'o'; usleep(100000); cout << 'W'; usleep(100000); cout << 'o'; usleep(100000); cout << 'r'; usleep(100000); cout << 'l'; usleep(100000); cout << 'd'; usleep(100000); } This is my code to print "Hello World" slowly I mean I'd like to print letters one by one Is there any function to do this in c++?

7th May 2021, 7:40 AM
Mani_K_A
8 Respostas
+ 2
after c++11 there is a thread library u can use it for this purpose. #include <iostream> #include <chrono> #include <thread> using namespace std; int main() { cout << "Hello I'm waiting...." << endl; this_thread::sleep_for(chrono::milliseconds(20000) ); cout << "Waited 20000 ms\n"; } code is got from https://www.google.com/amp/s/www.softwaretestinghelp.com/cpp-sleep/amp/
7th May 2021, 8:44 AM
Sharofiddin
Sharofiddin - avatar
+ 1
Martin Taylor you are one of the my mentors from c++. Thank you a lot. I regularly watch your posts and answers from Sololearn.
7th May 2021, 3:16 PM
Sharofiddin
Sharofiddin - avatar
+ 1
Sharofiddin a lot of people watch his answers every single day
7th May 2021, 4:32 PM
Rellot's screwdriver
Rellot's screwdriver - avatar
- 3
No My question was something ("Hello World") To print it slowly
7th May 2021, 8:08 AM
Mani_K_A