stringstream不接受空格? [英] stringstream doesn't accept white space?

查看:651
本文介绍了stringstream不接受空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

std::stringstream ss;
ss << 1 << "a b c";
std::string result;
ss >> result;
std::cout << result << std::endl;

我看到1a而不是1a bc。

I see "1a" instead of "1a b c".

我读的地方,我应该有<< std :: noskip。

I read somewhere that I should have ss << std::noskip. But it doesn't help.

任何想法?

提前感谢。

推荐答案

std::getline(ss, result);

或者,只要取得 string >

or, just get string

result = ss.str();

这篇关于stringstream不接受空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆