what is getline in c++ code example
Example 1: how to read a line from the console in c++
#include <string>
std::string str;
std::getline(std::cin, str);
Example 2: getline cpp
#include <iostream>
#include <string>
int main()
{
string namePerson{};
getline(cin, namePerson);
std::cout << namePerson;
}
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;
}