C++ string and cin problem. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

C++ string and cin problem.

When using a full name like "John Doe" it output bad resul. https://code.sololearn.com/cVJOpch5ZfLx/?ref=app

23rd Apr 2020, 11:30 PM
Ibrahim Kelly
Ibrahim Kelly - avatar
4 Answers
+ 4
Use getline(cin, string);
23rd Apr 2020, 11:36 PM
Mustafa K.
Mustafa K. - avatar
+ 4
Fully done! Thank you so much.
24th Apr 2020, 4:43 AM
Ibrahim Kelly
Ibrahim Kelly - avatar
+ 3
Yeah it's done, but it doesn't ask for age.
23rd Apr 2020, 11:46 PM
Ibrahim Kelly
Ibrahim Kelly - avatar
+ 2
It is because of sololearn. You need to enter your inputs like this when it asks, John Doe 10
23rd Apr 2020, 11:49 PM
Mustafa K.
Mustafa K. - avatar