+ 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++?
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/
+ 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.
+ 1
Sharofiddin a lot of people watch his answers every single day
- 3
No
My question was
something ("Hello World")
To print it slowly