Why does this stop at spaces? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why does this stop at spaces?

https://code.sololearn.com/c4ijn3MBIiP6/?ref=app Input anything with a space and it will stop once it encounters the space. Why?

31st Oct 2018, 5:25 AM
Daniel Cooper
Daniel Cooper - avatar
4 Answers
+ 3
In line 7, use getline(cin, str); Then you can read a whole line, including spaces. Hope that helps :)
31st Oct 2018, 5:36 AM
Kishalaya Saha
Kishalaya Saha - avatar
+ 1
Replace that line completely 😊
31st Oct 2018, 5:41 AM
Kishalaya Saha
Kishalaya Saha - avatar
+ 1
Ah. I get it. Thanks!
31st Oct 2018, 5:45 AM
Daniel Cooper
Daniel Cooper - avatar
0
Where in line 7? Replace cin, or after it?
31st Oct 2018, 5:40 AM
Daniel Cooper
Daniel Cooper - avatar