Answers for "how to get line input from user in cpp"

C++
20

get line C++

// extract to string
#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;
}
Posted by: Guest on November-16-2019
0

input full line as input in cpp

string line;

while (getline(cin, line)) {
    // do something with the line
}
Posted by: Guest on December-29-2021

Code answers related to "how to get line input from user in cpp"

Browse Popular Code Answers by Language