我尝试编写一个函数,以便检测是否接近stringstream的末尾,但似乎不起作用。
这是一些代码:
这是一些代码:
std::string path(1.2.3);
int number;
std::stringstream ss(path);
while (!ss.eof()) {
if (ss.peek() != '.') {
ss >> number;
if (ss.tellg() == path.length()) {
std::cout << "Last one: " << number;
} else {
std::cout << number;
}
} else { ss.get(); }
}
我尝试使用ss.tellg() == path.length(),但是不起作用。有人有其他方法吗?