【发布时间】:2013-05-10 12:17:18
【问题描述】:
std::string s;
std::stringstream ss;
ss << "a=b+c" << std::endl << "d=e+f";
std::getline(ss, s, '='); // gives me "a"
std::getline(ss, s); /* gives me "b+c" <- just want to peek: don't
want to change state of ss */
std::getline(ss, s, '+'); // BUT still want "b" here, not "d=e"
s 现在包含"a" 现在,我如何查看 行的剩余字符 ("b+c")?也就是说,不会导致下一个操作从下一行开始?
(我知道这是人为的例子。)
【问题讨论】:
标签: c++ getline stringstream