+ 2
How can I write cool?
I mean, how can I print something on the output, using the while loop and the output appear like someone is writing it right that time.
4 ответов
+ 8
@visph is right.
The stuff I used to do on Windows though.
for (char i : str)
{
cout << i;
Sleep(30);
}
// something similar, but without enhanced for loops and much more complex with conditional statements evaluating commas, marks and other symbols.
+ 4
By outputing char by char, with some delay between each (you can even introduce some randomized delay to get a more natural effect than too much regularly char output ^^)
Anyway, you cannot handle this kind of timed effect on code playground due to in/output limitations (except in web project, where in/output are differently handled ;))
0
I actually wrote something like this in Ruby. It went,
def type(str)
each_char.str do |x|
print x
sleep(0.9)
end
end
type "hello"