how can i delay my console program when executing?

Mar 21, 2018 at 3:39am
hello guys. am creating a console application and i hav a problems

1). i wanna let my program delay befor other output. like delaying in 1second before continuing outputing other statements. pls tell me how?

2). i wanna let my program output a sentences by outputing each letter one by one, as if the computer is writting?
help guys tanks.
Mar 21, 2018 at 9:07am
Mar 21, 2018 at 4:01pm
Hello jamesgodspower,

After you read coder777's link it would boil down to:
std::this_thread::sleep_for(std::chrono::seconds(?)); // Requires header files "chrono" and "thread"
Where the ? is the number of seconds to wait. You could change seconds to milliseconds for a more precise or shorter than a second.

Hope that helps,

Andy
Apr 1, 2018 at 7:16am
tanks
Apr 1, 2018 at 7:24am
To 1. if you use Windows and can't use C++11 then Sleep is an option - requires windows.h.
https://msdn.microsoft.com/en-us/library/windows/desktop/ms686298(v=vs.85).aspx

To 2. loop through your string and display each character separately. You need to convert numbers as string.
Topic archived. No new replies allowed.