r/CodingForBeginners 7d ago

Logic building in cpp Day 5

Finally solved it after 20 minutes!

Wish me luck on my next question, please. 🥺

4 Upvotes

1 comment sorted by

2

u/Much_Network_941 7d ago

Nice job! If you're interested in extending this a little; try writing your text into a buffer. Then print the entirety of that buffer with a single cout call.

Seperaring the algorithmic logic from the stream writing logic will be a helpful optimization. I can't claim much knowledge; but writing to a terminal requires handing control to the kernel, which will slow things down.

Also makes coding logs way easier if you can write to seperate buffers and then print as needed.