getline函数
定义:
istream& getline (istream& is, string& str, char delim);
istream& getline (istream& is, string& str);
示例:
// 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 << "!
";
return 0;
}
参考资料: