cin getline in c++ code example
Example 1: getline cpp
#include <iostream>
#include <string>
int main()
{
string namePerson{};
getline(cin, namePerson);
std::cout << namePerson;
}
Example 2: c++ reading string
#include <iostream>
#include <string>
string str;
getline(cin, str);
Example 3: get line C++
#include <iostream>
#include <string>
int main ()
{
std::string name;
std::cout << "Please, enter your full name: ";
std::getline (std::cin,name);
std::cout << "Hello, " << name << "!\n";
return 0;
}