请考虑以下代码:
std::stringstream test;
test << std::string("This is a test.");
std::string str;
test >> str;
std::cout << "\"" << str << "\"" << std::endl;
这仅输出字符串“This”,而不是“This is a test”。
为什么会这样,我怎样才能得到整个字符串?
请考虑以下代码:
std::stringstream test;
test << std::string("This is a test.");
std::string str;
test >> str;
std::cout << "\"" << str << "\"" << std::endl;
这仅输出字符串“This”,而不是“This is a test”。
为什么会这样,我怎样才能得到整个字符串?