+ 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😥
4 Antworten
+ 7
Can you show the code..
It should be something like
string name;
getline(cin, name);
cin >> name; //Your name here
cout<<name;
+ 5
Abdul Malik Make it like how I've stated.. you should ask for input after getline(cin, name)
That should work
0
well it was like
cout<<"enter name";
getline(cin,name)
cout<<name;
0
okay thank you😊