3.2.2 string对象上的操作-使用getline读取一整行

版权声明:本文为博主原创文章,未经博主允许不得转载 https://blog.csdn.net/qit1314/article/details/90046300

书中页数:P78
代码名称:getline.cc

#include <string> 
using std::string; using std::getline;

#include <iostream> 
using std::cin; using std::cout; using std::endl;

int main() 
{
	string line;

	// read input a line at a time until end-of-file
	while (getline(cin, line))
		cout << line << endl;

	return 0;
}

猜你喜欢

转载自blog.csdn.net/qit1314/article/details/90046300