Share your repls and programming experiences

← Back to all posts
C++ slowprint
SilentShadowBla (555)

For people who are doing c++ and want a slowprint function, this took me a LONG time to figure out probs cuz im dumb...:)

Mapaor4 (4)

Can u explain me the:

for(char c: word)

Never seen it

SilentShadowBla (555)

that basically saying as long as there are still characters in the string it will repeat the action @Mapaor4

Mapaor4 (4)

@SilentShadowBla Would this had been correct?:

for(int i = 0; i < word.size(); i++){
    cout << word[i] << flush;
SilentShadowBla (555)

yes longer but still effective @Mapaor4

ApoorvAgrawal (51)

@Mapaor4 It's a for-each loop. It's the same thing as for (x of cars) in javascript.

Roar123 (446)

This is nice! I don't know C++ and I can still appreciate it :)

AshleighBonner (0)

Thanks. I learned new functions. Great job!

Highwayman (1503)

REALLY nice code. very clean!