C++ 基础

getline

2017-09-14  本文已影响29人  费曼猫

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

http://www.cplusplus.com/reference/string/string/getline/

深入理解stringstream: http://www.cplusplus.com/reference/sstream/stringstream/

深入理解sstream: http://www.cplusplus.com/reference/sstream/

上一篇 下一篇

猜你喜欢

热点阅读