Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2
It's because when it checks if str[n] is a space, it checks it 52 times and therefore printing 52 spaces. You should put a break statement after the cout<<' '; statement.
30th Mar 2020, 2:12 PM
CeePlusPlus
CeePlusPlus - avatar