您的当前位置:首页正文

getline

来源:要发发知识网

std::getline (string) 继承于<string>
getline from stream into string

#include <iostream>
#include <string>
using namespace std;
int main(){
  string name;
  cout << "Please enter your name: "<< endl;
  getline(cin, name);
  cout << "Hello " << name << endl;
}

Extension: learn stringstream() getline() and struct together