How can I write cool? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 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.

14th Jul 2017, 3:19 PM
MintyNerdyPoodle
MintyNerdyPoodle - avatar
3 Respuestas
+ 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.
14th Jul 2017, 3:40 PM
Hatsy Rei
Hatsy Rei - avatar
+ 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 ;))
14th Jul 2017, 3:32 PM
visph
visph - avatar
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"
15th Jul 2017, 4:36 AM
Chris L.