c++中的getline()函数怎么使用,有什么功能

来源:百度知道 编辑:UC知道 时间:2024/06/13 13:34:11

看你想用哪个啦~~
键盘输入:
string s;
getline( cin, s );
cout << "You entered " << s << endl;
文件输入:
ifstream fin("tmp.dat");

int MAX_LENGTH = 100;
char line[MAX_LENGTH];

while( fin.getline(line, MAX_LENGTH) ) {
cout << "read line: " << line << endl;
}