Ok so i started coding on c++ today and i got a problem, i wrote a code that ak you your name and your surname and then it write "Welcome name surname, enjoy my program", i wrote a getline (cin, name) and a getline (cin, surname) so i can insert two words on surname but when it says Welcome name surname there's only one word.
#include <string>
#include <cmath>
using namespace std;
//add #include <string> to use string variable
//add #include <cmath> to use math functions
int main() {
//your name and surname
string name, surname;
cout << "Insert your name \n";
getline (cin, name);
cin >> name;
cout << "Insert your surname \n";
getline (cin, surname);
cin >> surname;
// cout is "Welcome Name Surname, enjoy my program :)"
cout << "Welcome " << name + " " + surname;
getline(cout, surname);
cout << ", enjoy my program :)";
// use getline (cin, name,); to insert more words on cin
return 0;
}
What do i have to do
why does it show only a word and not 2?