How do accept string input with spaces in c++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do accept string input with spaces in c++?

I m trying to take string input with spaces but its not getting with cin as it discards the second starring after space. kindly help me in this situation.

13th Jul 2018, 5:13 AM
Santosh Nagargoje
Santosh Nagargoje - avatar
7 Answers
13th Jul 2018, 5:26 AM
Vikas Gola
Vikas Gola - avatar
0
For starting - You can use char arrays to store string.
13th Jul 2018, 7:23 AM
Akib
Akib - avatar
0
but it doesn't accept next strings input.
13th Jul 2018, 2:02 PM
Santosh Nagargoje
Santosh Nagargoje - avatar
0
Santosh Nagargoje What do you mean it doesn't take input?
13th Jul 2018, 4:30 PM
Akib
Akib - avatar
0
when I press enter button after first string input. it doesn't take input for second string.
14th Jul 2018, 5:00 AM
Santosh Nagargoje
Santosh Nagargoje - avatar
0
You have to enter all the inputs at once. Write all the Inputs in different lines. Ex- Input 1 Input 2 Input 3 . .and so on.
14th Jul 2018, 5:41 AM
Akib
Akib - avatar
0
ok thanks
14th Jul 2018, 12:11 PM
Santosh Nagargoje
Santosh Nagargoje - avatar