string::getline
(1) |
istream& getline (istream& is, string& str, char delim); istream& getline (istream&& is, string& str, char delim); |
---|---|
(2) |
istream& getline (istream& is, string& str); istream& getline (istream&& is, string& str); |
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s1;
cout << "enter name:";//jiwawa
getline(std::cin, s1, 'a');//直到字符‘a’结束
cout << "s1:" << s1 << endl;//jiw
return 0;
}