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;
}

posted @ 2020-01-17 09:15  MoonXu  阅读(135)  评论(0编辑  收藏  举报