我正在尝试实现 istringstream
,以便在另一个 getline
操作中执行 getline
操作以从文本文件中读取文本,并执行所述文件中所述的操作 . 这是函数的代码:
fstream file(fileName);
string line;
string updateStat;
string updateLoc;
time_t updateTime;
while (getline(file, line)) {
if (line == "new")
continue;
else if (line != "new" || line != "back" || line != "forward") {
istringstream ss(line);
while (getline(ss, line, ';')) {
ss >> updateStat >> updateLoc >> updateTime;
m_addUpdate(updateStat, updateLoc, updateTime);
}
}
else if (line == "back")
m_moveBackward();
else if (line == "forward")
m_moveForward();
}
return (bool)file;
运行我的调试器后,我意识到 ss
的值不等于 line
的值 . 一切都在编译,但 ss
似乎还有其他一些数据 . 我在这里没有正确定义吗?