+ 2

Getline problems

Hi, i am a stud in software engineering course and i are having with getline use in C++. I wrote a variables 'name' and cin>>John Labu and i use getline(cin,name) to get the entire line.. but frustratingly... i only get Labu in cout<<name.. and ive been trying to find the problem.... hope someone can help me with thisđŸ˜„

11th Dec 2018, 2:35 PM
Abdul Malik
Abdul Malik - avatar
4 Answers
+ 7
Can you show the code.. It should be something like string name; getline(cin, name); cin >> name; //Your name here cout<<name;
11th Dec 2018, 3:00 PM
Frost
Frost - avatar
+ 5
Abdul Malik Make it like how I've stated.. you should ask for input after getline(cin, name) That should work
12th Dec 2018, 4:05 AM
Frost
Frost - avatar
0
well it was like cout<<"enter name"; getline(cin,name) cout<<name;
11th Dec 2018, 4:24 PM
Abdul Malik
Abdul Malik - avatar
0
okay thank you😊
12th Dec 2018, 2:58 PM
Abdul Malik
Abdul Malik - avatar