C++ 清除字符串流

C++ 清除字符串流,c++,fstream,stringstream,C++,Fstream,Stringstream,如何清除字符串流。我正在逐行标记一个文件,stringstream是全局的。我可以标记第一行,但第二行无法工作 stringstream currentLine; while (!inputFile.eof()) { currentLine << getlinefromfile(); //Gets the next Line tokenizeLine(); //Tokenizes the line using the global stringstream peek() fnc c

如何清除字符串流。我正在逐行标记一个文件,stringstream是全局的。我可以标记第一行,但第二行无法工作

stringstream currentLine;

while (!inputFile.eof())
{
currentLine << getlinefromfile(); //Gets the next Line
tokenizeLine(); //Tokenizes the line using the global stringstream peek() fnc
currentLine.str("");
currentLine.clear();
}

以上是我当前的尝试,但不起作用。

可能相关:在循环中声明currentLine变量。这些方法都不适用于我。我已经试过了,但是没有用。我看不出你的代码有什么问题。您是否尝试过在循环中实例化stringstream以查看错误是否位于其他位置?当然,你必须把它作为一个参数传递给tokenizeLine。你说它不起作用是什么意思??什么不起作用?