0

I have just started learning C++ and I created the following code:

std::string fName, lName;
std::cout << "Enter your first name" << std::endl ; 
std::cin >> fName ;
std::cout << "\nEnter your last name" << std::endl ; 
std::cin >> lName ;
std::cout << "\nHello " << fName << " " << lName ;
return 0;

But I noticed if I enter a name full name for fName i.e. "John Doe" lName get skipped but the code still prints out "Hello John Doe".

Could someone please explain why this behaviour occurs

Platinum
  • 23
  • 5

0 Answers0